MF_EasyScan_Targeting
This is the base targeting component with just targeting logic, and should be used with a unity that already has an MF_EasyScan component. Use this if you want a unit to have more than one target.
Public Interface IScanEvents
Offers an alternate way to track scan and targeting states. In this case, the MF_EasyScan can send a ScanEventType to any class that implements IScanEvents.
ScanEvent : void ( eventType : ScanEventType, target : MF_EasyScan )
enum ScanEventType { ScanPulse, NewEnemyScan, NewNeutralScan, NewAllyScan, NewUnknownScan, NewTarget, LostTarget }
ScanPulse - Sends this event every time the scanner updates according to the scanInterval. target will return null.
NewEnemyScan - Sent if a newely detected target is an enemy.
NewNeutralScan - If a newely detected target is neutral.
NewAllyScan - If a newely detected target is an ally.
NewUnknownScan - If a newely detected target is of an unknown relation.
NewTarget - Sends this event every time a new target is selected.
LostTarget - Sent upon loosing a target that is not replaced. target will return null.
Stat Interfaces
Allows other scripts on this component to implement various stat methods that can be referenced by MF_EasyScan for targeting preferences.
IGetShield -> GetShield : float (), GetShieldMax : float ()
IGetArmor -> GetArmor : float (), GetArmorMax : float ()
IGetHealth -> GetHealth : float (), GetHealthMax : float ()
IGetEnergy -> GetEnergy : float (), GetEnergyMax : float ()
IGetThreat -> GetThreat : float (), GetThreatMax : float ()
IGetCustomStat -> GetCustomStat : float (), GetCustomStatMax : float ()
IGetTotalStrength -> GetTotalStrength : float (), GetTotalStrengthMax : float ()
TotalStrength is intended to be a way to return a value combining any or all other stats, but implementation is ultimately up to the individual scripts.
Public Methods
AddEventTarget : void ( eventTarget : IScanEvents )
AddEventTarget : void ( gameObject : GameObject, eventTarget : IScanEvents )
Adds an object implementing IScanEvents as a receiver to a MF_EasyScan ScanEvents.
gameObject is an optional parameter during runtime, but it can serve as a visual indicator in the inspector, since the editor doesn't display interface types.
ChooseNewTarget : MF_EasyScan ( )
Force a target evaluation regardless of next targetingInterval, and will override the keepValidTarget flag.
GetTarget : MF_EasyScan ( )
Returns the MF_EasyScan script of the current target.
GetShield : float ( )
GetShieldMax : float ( )
GetArmor : float ( )
GetArmorMax : float ( )
GetHealth : float ( )
GetHealthMax : float ( )
GetEnergy : float ( )
GetEnergyMax : float ( )
GetThreat : float ( )
GetThreatMax : float ( )
GetCustomStat : float ( )
GetCustomStatMax : float ( )
GetTotalStrength : float ( )
GetTotalStrengthMax : float ( )
If any other components on this object have implemented following interfaces:
IShield, IArmor, IHealth, IEnergy, IThreat, ICustomStat, ITotalStrength
They can be referenced via MF_EasyTurret, and return the stat value, or the value as a percentage of the max, as individually implemented by that script.
GetVelocity : Vector3 ()
Returns the velocity of an attached Rigidbody or Rigidbody2D component.
GetVelocityMagnitude : float ()
Returns the velocity magnitude of an attached Rigidbody or Rigidbody2D component.
GetVelocitySqrMagnitude : float ()
Returns the velocity square magnitude of an attached Rigidbody or Rigidbody2D component.
RemoveEventTarget : void ( eventTarget : IScanEvents )
Removes an object implementing IScanEvents as a reciever of the scripts ScanEvents.
SetFilterWeaponRange : void ( max : float )
SetFilterWeaponRange : void ( max : float, includeTargetingRange : bool )
SetFilterWeaponRange : void ( min : float max : float )
SetFilterWeaponRange : void ( min : float, max : float, includeTargetingRange : bool )
Searches through any filters and sets any UseWeaponRange items to the specified range.
Setting includeTargetingRange to true will also call SetTargetingRange() as well.
SetTargetingRange : void ( max : float )
SetTargetingRange : void ( min : float, max : float , angle : float )
Sets the min and max targeting ranges, as well as any angle arc limitation.
Public Variables
targetingActive : bool
If true, allows targeting functions. If false, no targeting will performed.
targetingInterval : float
How often to re-evaluate targeting for the best target according to settings. keepValidTarget may skip re-evluation if the current target is still valid, despite the presence of a better target.
rangeMin : bool
The minimum range a target may have to remain valid.
rangeMax : bool
The maximum range a target may have to remain valid.
targetingAngle : bool
The angle a target may be within to remain valid.
mayTargetSelf : bool
Allowed to target self.
targetRequiresLoS : bool
A linecast will be performed to potential units, if blocked, they won't be valid targets.
targetLosLayerMask : LayerMask
Specifies which layers can block line-of-sight. Typical usage would be to have walls and tarrain block LoS without being blocked by other units .
targetRelationships : enum RelationType[ ] { Unknown, Enemies, Neutral, Allies }
Which relations targets must be to be a valid target. Faction relations are defined on MF_EasyScan_UnitList.
filters : MF_EasyScan.FilterBlock
A wrapper class for FilterBlock.
filterBlockImportance : enum FilterBlockImportance { Required, Preferred }
Required - A target must pass all filter requirements at all times. If no targets pass filters, no target will be selected.
Prefered - If no targets pass filters, then filters are ignored. Though targets must still be valid according to other criteria.
If keepValidTarget is true, a target will be kept even if it no longer passes filters.
keepValidTarget : bool
Will keep the current target until it becomes invalid, or fails to pass filters while filterBlockImportance is Required.
prefix : PriorityPrefix enum { Lowest, Highest }
Designate how to prioritize targets based on the priority criteria.
priority : PriorityType enum { Range, Speed, Health, HealthPercent, Shield, ShieldPercent, Armor, ArmorPercent, Energy,EnergyPercent, TotalStrength, TotalStrengthPercent }
The priority category with which to select a target.
relativeTo : enum RelativeTo { FromSelf, FromObject, FromUnit }
When using the Range priority, the comparison can be made of alternate positions.
FromSelf - Will compare from this units transform.position.
FromObject - Will compare from the transform.position of otherObject.
FromUnit - Will compare from the transform.position of otherObject, but if the object becomes disabled, it will be removed. Note that this reference will ignore any range or targeting limitations.
otherObject : GameObject
When using relativeTo FromObject or FromUnit, this is the object to use for transform.position.
audioBlock : AudioBlock
Wrapper class that contains various audio.
eventTargets : List<MF_EasyScan.ScanEventTargets>
Allows MF_ES_TargetingOnly to reference objects implementing IScanEvents. These objects will reviece ScanEvent items.
Public Class AudioBlock
ScanSounds only have any effect in MF_EasyScan.
scanSound : AudioSource
Soud to play at every scanInterval.
enemyScanSound : AudioSource
Sound to play when detecting a new enemy.
neutralScanSound : AudioSource
Sound to play when detecting a new neutral unit.
allyScanSound : AudioSource
Sound to play when detecting a new ally.
unknownScanSound : AudioSource
Sound to play when detecting a new unknown faction unit.
newTargetSound : AudioSource
Sound to play at every time a new target is aquired.
lostTargetSound : AudioSource
Sound to play at when having no target after previously having a target.
Public Class ScanEventTarget
A wrapper class is used because the editor doesn't serialize interfaces. The GameObjects will be searched for IScanEvents upon Awake()
gameObject : GameObject
[Hidden] IScanEvents : eventTarget
Public Class FilterBlock
filterItems : FilterItem[ ]
A list of this FilterBlock's filters.
Public Class FilterItem
major : bool
If true, designates this filter as an AND filter that must be passes.
If false, designates this filter as an OR filter. At least one of all marked OR filters must be passed.
filter : enum FilterType { None, Range, Class1, Class2, Role1, Role2, Health, Armor, Shield, Energy, TotalStrength, Speed, Relation, Faction, TargetingMe, NotTargetingMe, TargetingRelation, Targeting Faction, InWeaponRange }
None - An ignored entry.
Range - Compares the distance of the unit to a value.
Class1 - Compares the class1 of the unit to Class1.
Class2 - Compares the class2 of the unit to Class2.
Role1 - Compares the role1 of the unit to Role1.
Role2 - Compares the role2 of the unit to Role2.
Stat - Compares a selected stat to a value.
Speed - Compares the velocity magnitude of the unit to a value.
Relation - Compares the relation of this unit's faction to a RelationType.
Faction - Compares the faction of the unit to a FactionType.
Targeting - Compare all of the unit's targeting scripts to TargetType.
IsMyTarget - Compares own unit's targeting scripts (excluding the one doing the comparison) for their target.
InWeaponRange - Compares the distance of the unit to a min and max range value that is set by another script using SetFilterWeaponRange();
To use Health, Shield, Armor, Energy, and TotalStrength, another script must implement the corresponding interfaces for them (IHealth, IShield, IEnergy, ITotalStrength)
op : enum Operator { LessThan, LessOrEqual, Equals, MoreOrEqual, MoreThan, Not, Within }
The type of operator to use for comparison of the chosen filter.
Within - Is value within the range of two values. (Inclusive)
boolTest : enum BoolType { False, True }
The type of operator to use for comparison of the chosen filter.
relation : enum RelationType { Unknown, Enemy, Neutral, Ally }
When using the Relation filter, this sets the value to compare it to.
faction : enum FactionType { Editor, Side1, Side2 }
This enum may be changed to custom values.
When using the Faction filter, this sets the value to compare it to.
targetType : enum TargetType { Any, Me, Relation, Faction }
When using the Targeting filter, this sets the type of comparison.
class1 : enum Class1 { Unknown, Tiny, Small, Medium, Large, Huge }
This enum may be changed to custom values.
When using the Class1 filter, this sets the value to compare it to.
class2 : enum Class2 { Unknown, Weak, Normal, Elite, Boss }
This enum may be changed to custom values.
When using the Class2 filter, this sets the value to compare it to.
role1 : enum Role1 { Unknown, Tank, Support, Carrier, DPS, Heal }
This enum may be changed to custom values.
When using the Role1 filter, this sets the value to compare it to.
role2 : enum Role2 { Unknown, Short, Medium, Long }
This enum may be changed to custom values.
When using the Role2 filter, this sets the value to compare it to.
stat : enum StatType { Health, HealthPercent, Shield, ShieldPercent, Armor, ArmorPercent, Energy, EnergyPercent, TotalStrength, TotalStrengthPercent }
When using the Stat filter, this will be the item to compare to a value. Stat values are gathered from a script implementing one or more of the following interfaces: IHealth, IShield, IArmor, IEnergy, ITotalStrength.
value1 : float
When using a Range, Speed, Health, Shield, Armor, Energy, TotalStrength, or InWeapponRange filter, this sets the max value to compare it to.
value2 : float
When using a Range, Speed, Health, Shield, Armor, Energy, TotalStrength, or InWeapponRange filter, this sets the min value to compare it to.
relativeTo : enum RelativeTo { FromSelf, FromObject, FromUnit }
When using the Range filter, the comparison can be made of alternate positions.
FromSelf - Will compare from this units transform.position.
FromObject - Will compare from the transform.position of otherObject.
FromUnit - Will compare from the transform.position of otherObject, but if the object becomes disabled, it will be removed. Note that this reference will ignore any range or targeting limitations.
otherObject : gameObject
When using relativeTo FromObject or FromUnit, this is the object to use for transform.position.
This is the base targeting component with just targeting logic, and should be used with a unity that already has an MF_EasyScan component. Use this if you want a unit to have more than one target.
Public Interface IScanEvents
Offers an alternate way to track scan and targeting states. In this case, the MF_EasyScan can send a ScanEventType to any class that implements IScanEvents.
ScanEvent : void ( eventType : ScanEventType, target : MF_EasyScan )
enum ScanEventType { ScanPulse, NewEnemyScan, NewNeutralScan, NewAllyScan, NewUnknownScan, NewTarget, LostTarget }
ScanPulse - Sends this event every time the scanner updates according to the scanInterval. target will return null.
NewEnemyScan - Sent if a newely detected target is an enemy.
NewNeutralScan - If a newely detected target is neutral.
NewAllyScan - If a newely detected target is an ally.
NewUnknownScan - If a newely detected target is of an unknown relation.
NewTarget - Sends this event every time a new target is selected.
LostTarget - Sent upon loosing a target that is not replaced. target will return null.
Stat Interfaces
Allows other scripts on this component to implement various stat methods that can be referenced by MF_EasyScan for targeting preferences.
IGetShield -> GetShield : float (), GetShieldMax : float ()
IGetArmor -> GetArmor : float (), GetArmorMax : float ()
IGetHealth -> GetHealth : float (), GetHealthMax : float ()
IGetEnergy -> GetEnergy : float (), GetEnergyMax : float ()
IGetThreat -> GetThreat : float (), GetThreatMax : float ()
IGetCustomStat -> GetCustomStat : float (), GetCustomStatMax : float ()
IGetTotalStrength -> GetTotalStrength : float (), GetTotalStrengthMax : float ()
TotalStrength is intended to be a way to return a value combining any or all other stats, but implementation is ultimately up to the individual scripts.
Public Methods
AddEventTarget : void ( eventTarget : IScanEvents )
AddEventTarget : void ( gameObject : GameObject, eventTarget : IScanEvents )
Adds an object implementing IScanEvents as a receiver to a MF_EasyScan ScanEvents.
gameObject is an optional parameter during runtime, but it can serve as a visual indicator in the inspector, since the editor doesn't display interface types.
ChooseNewTarget : MF_EasyScan ( )
Force a target evaluation regardless of next targetingInterval, and will override the keepValidTarget flag.
GetTarget : MF_EasyScan ( )
Returns the MF_EasyScan script of the current target.
GetShield : float ( )
GetShieldMax : float ( )
GetArmor : float ( )
GetArmorMax : float ( )
GetHealth : float ( )
GetHealthMax : float ( )
GetEnergy : float ( )
GetEnergyMax : float ( )
GetThreat : float ( )
GetThreatMax : float ( )
GetCustomStat : float ( )
GetCustomStatMax : float ( )
GetTotalStrength : float ( )
GetTotalStrengthMax : float ( )
If any other components on this object have implemented following interfaces:
IShield, IArmor, IHealth, IEnergy, IThreat, ICustomStat, ITotalStrength
They can be referenced via MF_EasyTurret, and return the stat value, or the value as a percentage of the max, as individually implemented by that script.
GetVelocity : Vector3 ()
Returns the velocity of an attached Rigidbody or Rigidbody2D component.
GetVelocityMagnitude : float ()
Returns the velocity magnitude of an attached Rigidbody or Rigidbody2D component.
GetVelocitySqrMagnitude : float ()
Returns the velocity square magnitude of an attached Rigidbody or Rigidbody2D component.
RemoveEventTarget : void ( eventTarget : IScanEvents )
Removes an object implementing IScanEvents as a reciever of the scripts ScanEvents.
SetFilterWeaponRange : void ( max : float )
SetFilterWeaponRange : void ( max : float, includeTargetingRange : bool )
SetFilterWeaponRange : void ( min : float max : float )
SetFilterWeaponRange : void ( min : float, max : float, includeTargetingRange : bool )
Searches through any filters and sets any UseWeaponRange items to the specified range.
Setting includeTargetingRange to true will also call SetTargetingRange() as well.
SetTargetingRange : void ( max : float )
SetTargetingRange : void ( min : float, max : float , angle : float )
Sets the min and max targeting ranges, as well as any angle arc limitation.
Public Variables
targetingActive : bool
If true, allows targeting functions. If false, no targeting will performed.
targetingInterval : float
How often to re-evaluate targeting for the best target according to settings. keepValidTarget may skip re-evluation if the current target is still valid, despite the presence of a better target.
rangeMin : bool
The minimum range a target may have to remain valid.
rangeMax : bool
The maximum range a target may have to remain valid.
targetingAngle : bool
The angle a target may be within to remain valid.
mayTargetSelf : bool
Allowed to target self.
targetRequiresLoS : bool
A linecast will be performed to potential units, if blocked, they won't be valid targets.
targetLosLayerMask : LayerMask
Specifies which layers can block line-of-sight. Typical usage would be to have walls and tarrain block LoS without being blocked by other units .
targetRelationships : enum RelationType[ ] { Unknown, Enemies, Neutral, Allies }
Which relations targets must be to be a valid target. Faction relations are defined on MF_EasyScan_UnitList.
filters : MF_EasyScan.FilterBlock
A wrapper class for FilterBlock.
filterBlockImportance : enum FilterBlockImportance { Required, Preferred }
Required - A target must pass all filter requirements at all times. If no targets pass filters, no target will be selected.
Prefered - If no targets pass filters, then filters are ignored. Though targets must still be valid according to other criteria.
If keepValidTarget is true, a target will be kept even if it no longer passes filters.
keepValidTarget : bool
Will keep the current target until it becomes invalid, or fails to pass filters while filterBlockImportance is Required.
prefix : PriorityPrefix enum { Lowest, Highest }
Designate how to prioritize targets based on the priority criteria.
priority : PriorityType enum { Range, Speed, Health, HealthPercent, Shield, ShieldPercent, Armor, ArmorPercent, Energy,EnergyPercent, TotalStrength, TotalStrengthPercent }
The priority category with which to select a target.
relativeTo : enum RelativeTo { FromSelf, FromObject, FromUnit }
When using the Range priority, the comparison can be made of alternate positions.
FromSelf - Will compare from this units transform.position.
FromObject - Will compare from the transform.position of otherObject.
FromUnit - Will compare from the transform.position of otherObject, but if the object becomes disabled, it will be removed. Note that this reference will ignore any range or targeting limitations.
otherObject : GameObject
When using relativeTo FromObject or FromUnit, this is the object to use for transform.position.
audioBlock : AudioBlock
Wrapper class that contains various audio.
eventTargets : List<MF_EasyScan.ScanEventTargets>
Allows MF_ES_TargetingOnly to reference objects implementing IScanEvents. These objects will reviece ScanEvent items.
Public Class AudioBlock
ScanSounds only have any effect in MF_EasyScan.
scanSound : AudioSource
Soud to play at every scanInterval.
enemyScanSound : AudioSource
Sound to play when detecting a new enemy.
neutralScanSound : AudioSource
Sound to play when detecting a new neutral unit.
allyScanSound : AudioSource
Sound to play when detecting a new ally.
unknownScanSound : AudioSource
Sound to play when detecting a new unknown faction unit.
newTargetSound : AudioSource
Sound to play at every time a new target is aquired.
lostTargetSound : AudioSource
Sound to play at when having no target after previously having a target.
Public Class ScanEventTarget
A wrapper class is used because the editor doesn't serialize interfaces. The GameObjects will be searched for IScanEvents upon Awake()
gameObject : GameObject
[Hidden] IScanEvents : eventTarget
Public Class FilterBlock
filterItems : FilterItem[ ]
A list of this FilterBlock's filters.
Public Class FilterItem
major : bool
If true, designates this filter as an AND filter that must be passes.
If false, designates this filter as an OR filter. At least one of all marked OR filters must be passed.
filter : enum FilterType { None, Range, Class1, Class2, Role1, Role2, Health, Armor, Shield, Energy, TotalStrength, Speed, Relation, Faction, TargetingMe, NotTargetingMe, TargetingRelation, Targeting Faction, InWeaponRange }
None - An ignored entry.
Range - Compares the distance of the unit to a value.
Class1 - Compares the class1 of the unit to Class1.
Class2 - Compares the class2 of the unit to Class2.
Role1 - Compares the role1 of the unit to Role1.
Role2 - Compares the role2 of the unit to Role2.
Stat - Compares a selected stat to a value.
Speed - Compares the velocity magnitude of the unit to a value.
Relation - Compares the relation of this unit's faction to a RelationType.
Faction - Compares the faction of the unit to a FactionType.
Targeting - Compare all of the unit's targeting scripts to TargetType.
IsMyTarget - Compares own unit's targeting scripts (excluding the one doing the comparison) for their target.
InWeaponRange - Compares the distance of the unit to a min and max range value that is set by another script using SetFilterWeaponRange();
To use Health, Shield, Armor, Energy, and TotalStrength, another script must implement the corresponding interfaces for them (IHealth, IShield, IEnergy, ITotalStrength)
op : enum Operator { LessThan, LessOrEqual, Equals, MoreOrEqual, MoreThan, Not, Within }
The type of operator to use for comparison of the chosen filter.
Within - Is value within the range of two values. (Inclusive)
boolTest : enum BoolType { False, True }
The type of operator to use for comparison of the chosen filter.
relation : enum RelationType { Unknown, Enemy, Neutral, Ally }
When using the Relation filter, this sets the value to compare it to.
faction : enum FactionType { Editor, Side1, Side2 }
This enum may be changed to custom values.
When using the Faction filter, this sets the value to compare it to.
targetType : enum TargetType { Any, Me, Relation, Faction }
When using the Targeting filter, this sets the type of comparison.
class1 : enum Class1 { Unknown, Tiny, Small, Medium, Large, Huge }
This enum may be changed to custom values.
When using the Class1 filter, this sets the value to compare it to.
class2 : enum Class2 { Unknown, Weak, Normal, Elite, Boss }
This enum may be changed to custom values.
When using the Class2 filter, this sets the value to compare it to.
role1 : enum Role1 { Unknown, Tank, Support, Carrier, DPS, Heal }
This enum may be changed to custom values.
When using the Role1 filter, this sets the value to compare it to.
role2 : enum Role2 { Unknown, Short, Medium, Long }
This enum may be changed to custom values.
When using the Role2 filter, this sets the value to compare it to.
stat : enum StatType { Health, HealthPercent, Shield, ShieldPercent, Armor, ArmorPercent, Energy, EnergyPercent, TotalStrength, TotalStrengthPercent }
When using the Stat filter, this will be the item to compare to a value. Stat values are gathered from a script implementing one or more of the following interfaces: IHealth, IShield, IArmor, IEnergy, ITotalStrength.
value1 : float
When using a Range, Speed, Health, Shield, Armor, Energy, TotalStrength, or InWeapponRange filter, this sets the max value to compare it to.
value2 : float
When using a Range, Speed, Health, Shield, Armor, Energy, TotalStrength, or InWeapponRange filter, this sets the min value to compare it to.
relativeTo : enum RelativeTo { FromSelf, FromObject, FromUnit }
When using the Range filter, the comparison can be made of alternate positions.
FromSelf - Will compare from this units transform.position.
FromObject - Will compare from the transform.position of otherObject.
FromUnit - Will compare from the transform.position of otherObject, but if the object becomes disabled, it will be removed. Note that this reference will ignore any range or targeting limitations.
otherObject : gameObject
When using relativeTo FromObject or FromUnit, this is the object to use for transform.position.