| enum EWetnessLevel |
| { |
| DRY, |
| DAMP, |
| WET, |
| SOAKING, |
| DRENCHED |
| } |
|
|
| enum SurfaceAnimationBone |
| { |
| LeftFrontLimb = 0, |
| RightFrontLimb, |
| LeftBackLimb, |
| RightBackLimb |
| } |
|
|
| enum PlantType |
| { |
| TREE_HARD = 1000, |
| TREE_SOFT = 1001, |
| BUSH_HARD = 1002, |
| BUSH_SOFT = 1003, |
| } |
|
|
| enum WeightUpdateType |
| { |
| FULL = 0, |
| ADD, |
| REMOVE, |
| RECURSIVE_ADD, |
| RECURSIVE_REMOVE |
| } |
|
|
| enum EItemManipulationContext |
| { |
| UPDATE, |
| ATTACHING, |
| DETACHING, |
| } |
|
|
| |
| enum EInventoryIconVisibility |
| { |
| ALWAYS = 0, |
| HIDE_VICINITY = 1, |
| |
| HIDE_PLAYER_CONTAINER = 2, |
| HIDE_HANDS_SLOT = 4 |
| } |
|
|
| |
| enum EAttExclusions |
| { |
| OCCUPANCY_INVALID = -1, |
| |
| LEGACY_EYEWEAR_HEADGEAR, |
| LEGACY_EYEWEAR_MASK, |
| LEGACY_HEADSTRAP_HEADGEAR, |
| LEGACY_HEADSTRAP_MASK, |
| LEGACY_HEADGEAR_MASK, |
| LEGACY_HEADGEAR_EYEWEWEAR, |
| LEGACY_HEADGEAR_HEADSTRAP, |
| LEGACY_MASK_HEADGEAR, |
| LEGACY_MASK_EYEWEWEAR, |
| LEGACY_MASK_HEADSTRAP, |
| |
| EXCLUSION_HEADGEAR_HELMET_0, |
| |
| EXCLUSION_HEADSTRAP_0, |
| EXCLUSION_MASK_0, |
| EXCLUSION_MASK_1, |
| EXCLUSION_MASK_2, |
| EXCLUSION_MASK_3, |
| EXCLUSION_GLASSES_REGULAR_0, |
| EXCLUSION_GLASSES_TIGHT_0, |
| |
| SHAVING_MASK_ATT_0, |
| SHAVING_HEADGEAR_ATT_0, |
| SHAVING_EYEWEAR_ATT_0, |
| } |
|
|
| class DebugSpawnParams |
| { |
| Man m_Player; |
|
|
| static DebugSpawnParams WithPlayer(Man player) |
| { |
| DebugSpawnParams params = new DebugSpawnParams(); |
| params.m_Player = player; |
| return params; |
| } |
| }; |
|
|
| class TSelectableActionInfoArrayEx extends array<ref Param> {} |
| typedef Param3<int, int, string> TSelectableActionInfo; |
| typedef Param4<int, int, string, int> TSelectableActionInfoWithColor; |
|
|
| class EntityAI extends Entity |
| { |
| bool m_DeathSyncSent; |
| bool m_KilledByHeadshot; |
| bool m_PreparedToDelete = false; |
| bool m_RefresherViable = false; |
| bool m_WeightDirty = 1; |
| private ref map<int,ref set<int>> m_AttachmentExclusionSlotMap; |
| private ref set<int> m_AttachmentExclusionMaskGlobal; |
| private ref set<int> m_AttachmentExclusionMaskChildren; |
| |
| ref DestructionEffectBase m_DestructionBehaviourObj; |
| |
| ref KillerData m_KillerData; |
| private ref HiddenSelectionsData m_HiddenSelectionsData; |
| |
| const int DEAD_REPLACE_DELAY = 2000; |
| const int DELETE_CHECK_DELAY = 100; |
| |
| ref array<EntityAI> m_AttachmentsWithCargo; |
| ref array<EntityAI> m_AttachmentsWithAttachments; |
| ref InventoryLocation m_OldLocation; |
| |
| protected ref DamageZoneMap m_DamageZoneMap; |
| private ref map<int, string> m_DamageDisplayNameMap = new map<int, string>; |
| |
| float m_Weight; |
| float m_WeightEx; |
| float m_ConfigWeight = ConfigGetInt("weight"); |
| protected bool m_CanDisplayWeight; |
| private float m_LastUpdatedTime; |
| protected float m_ElapsedSinceLastUpdate; |
| |
| protected UTemperatureSource m_UniversalTemperatureSource; |
| |
| bool m_PendingDelete = false; |
| bool m_Initialized = false; |
| bool m_TransportHitRegistered = false; |
| vector m_TransportHitVelocity; |
| |
| |
| protected ref ScriptInvoker m_OnItemAttached; |
| |
| protected ref ScriptInvoker m_OnItemDetached; |
| |
| protected ref ScriptInvoker m_OnItemAddedIntoCargo; |
| |
| protected ref ScriptInvoker m_OnItemRemovedFromCargo; |
| |
| protected ref ScriptInvoker m_OnItemMovedInCargo; |
| |
| protected ref ScriptInvoker m_OnItemFlipped; |
| |
| protected ref ScriptInvoker m_OnViewIndexChanged; |
| |
| protected ref ScriptInvoker m_OnSetLock; |
| |
| protected ref ScriptInvoker m_OnReleaseLock; |
| |
| protected ref ScriptInvoker m_OnAttachmentSetLock; |
| |
| protected ref ScriptInvoker m_OnAttachmentReleaseLock; |
| |
| protected ref ScriptInvoker m_OnHitByInvoker; |
| |
| protected ref ScriptInvoker m_OnKilledInvoker; |
| |
| void EntityAI() |
| { |
| |
| string type = GetType(); |
| string param_access_energy_sys = "CfgVehicles " + type + " EnergyManager "; |
| bool is_electic_device = GetGame().ConfigIsExisting(param_access_energy_sys); |
|
|
| if (is_electic_device) |
| { |
| CreateComponent(COMP_TYPE_ENERGY_MANAGER); |
| RegisterNetSyncVariableBool("m_EM.m_IsSwichedOn"); |
| RegisterNetSyncVariableBool("m_EM.m_CanWork"); |
| RegisterNetSyncVariableBool("m_EM.m_IsPlugged"); |
| RegisterNetSyncVariableInt("m_EM.m_EnergySourceNetworkIDLow"); |
| RegisterNetSyncVariableInt("m_EM.m_EnergySourceNetworkIDHigh"); |
| RegisterNetSyncVariableFloat("m_EM.m_Energy"); |
| } |
| |
| |
| RegisterNetSyncVariableInt( "m_ViewIndex", 0, 99 ); |
| |
| RegisterNetSyncVariableBool("m_RefresherViable"); |
| |
| m_AttachmentsWithCargo = new array<EntityAI>(); |
| m_AttachmentsWithAttachments = new array<EntityAI>(); |
| m_LastUpdatedTime = 0.0; |
| m_ElapsedSinceLastUpdate = 0.0; |
| |
| m_CanDisplayWeight = ConfigGetBool("displayWeight"); |
| |
| InitDamageZoneMapping(); |
| InitDamageZoneDisplayNameMapping(); |
| |
| m_HiddenSelectionsData = new HiddenSelectionsData( GetType() ); |
| |
| GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DeferredInit,34); |
| } |
| |
| void ~EntityAI() |
| { |
| |
| } |
| |
| void DeferredInit() |
| { |
| m_Initialized = true; |
| } |
| |
| bool IsInitialized() |
| { |
| return m_Initialized; |
| } |
| |
| |
| int GetHideIconMask() |
| { |
| return EInventoryIconVisibility.ALWAYS; |
| } |
|
|
| private ref ComponentsBank m_ComponentsBank; |
| ComponentEnergyManager m_EM; |
|
|
| |
| Component CreateComponent(int comp_type, string extended_class_name="") |
| { |
| return GetComponent(comp_type, extended_class_name); |
| } |
|
|
| |
| Component GetComponent(int comp_type, string extended_class_name="") |
| { |
| if ( m_ComponentsBank == NULL ) |
| m_ComponentsBank = new ComponentsBank(this); |
| |
| return m_ComponentsBank.GetComponent(comp_type, extended_class_name); |
| } |
|
|
| |
| bool DeleteComponent(int comp_type) |
| { |
| return m_ComponentsBank.DeleteComponent(comp_type); |
| } |
| |
| string GetDestructionBehaviour() |
| { |
| return ""; |
| } |
| |
| bool IsDestructionBehaviour() |
| { |
| return false; |
| } |
| |
| |
| bool HasComponent(int comp_type) |
| { |
| if ( m_ComponentsBank ) |
| return m_ComponentsBank.IsComponentAlreadyExist(comp_type); |
| |
| return false; |
| } |
| |
| |
| void MaxLifetimeRefreshCalc() |
| { |
| if ( (!GetGame().IsMultiplayer() || GetGame().IsServer()) && GetEconomyProfile() ) |
| { |
| float lifetime = GetEconomyProfile().GetLifetime(); |
| int frequency = GetCEApi().GetCEGlobalInt("FlagRefreshFrequency"); |
| if ( frequency <= 0 ) |
| { |
| frequency = GameConstants.REFRESHER_FREQUENCY_DEFAULT; |
| } |
| |
| if ( frequency <= lifetime ) |
| { |
| m_RefresherViable = true; |
| SetSynchDirty(); |
| } |
| } |
| } |
| |
| bool IsRefresherSignalingViable() |
| { |
| if (IsRuined()) |
| { |
| return false; |
| } |
| return m_RefresherViable; |
| } |
| |
| #ifdef DEVELOPER |
| override void SetDebugItem() |
| { |
| super.SetDebugItem(); |
| _item = this; |
| } |
| #endif |
| |
| |
| |
| void InitDamageZoneMapping() |
| { |
| m_DamageZoneMap = new DamageZoneMap; |
| DamageSystem.GetDamageZoneMap(this,m_DamageZoneMap); |
| } |
| |
| |
| void InitDamageZoneDisplayNameMapping() |
| { |
| string path_base; |
| string path; |
| string component_name; |
| |
| if ( IsWeapon() ) |
| { |
| path_base = CFG_WEAPONSPATH; |
| } |
| else if ( IsMagazine() ) |
| { |
| path_base = CFG_MAGAZINESPATH; |
| } |
| else |
| { |
| path_base = CFG_VEHICLESPATH; |
| } |
| |
| path_base = string.Format( "%1 %2 DamageSystem DamageZones", path_base, GetType() ); |
| |
| if ( !GetGame().ConfigIsExisting(path_base) ) |
| { |
| component_name = GetDisplayName(); |
| GetGame().FormatRawConfigStringKeys(component_name); |
| m_DamageDisplayNameMap.Insert( "".Hash(), component_name ); |
| } |
| else |
| { |
| TStringArray zone_names = new TStringArray; |
| GetDamageZones( zone_names ); |
| |
| for ( int i = 0; i < zone_names.Count(); i++ ) |
| { |
| path = string.Format( "%1 %2 displayName", path_base, zone_names[i] ); |
| |
| if (GetGame().ConfigIsExisting(path) && GetGame().ConfigGetTextRaw(path,component_name)) |
| { |
| GetGame().FormatRawConfigStringKeys(component_name); |
| m_DamageDisplayNameMap.Insert( zone_names[i].Hash(), component_name ); |
| } |
| } |
| } |
| } |
| |
| protected float ConvertNonlethalDamage(float damage, DamageType damageType) |
| { |
| return 0.0; |
| } |
| |
| |
| float ConvertNonlethalDamage(float damage) |
| { |
| return 0.0; |
| } |
| |
| DamageZoneMap GetEntityDamageZoneMap() |
| { |
| return m_DamageZoneMap; |
| } |
| |
| map<int, string> GetEntityDamageDisplayNameMap() |
| { |
| return m_DamageDisplayNameMap; |
| } |
| |
| |
| bool CanDisplayWeight() |
| { |
| return m_CanDisplayWeight; |
| } |
|
|
| |
| void Log(string msg, string fnc_name = "n/a") |
| { |
| Debug.Log(msg, "Object", "n/a", fnc_name, this.GetType()); |
| } |
|
|
| |
| void LogWarning(string msg, string fnc_name = "n/a") |
| { |
| Debug.LogWarning(msg, "Object", "n/a", fnc_name, this.GetType()); |
| } |
|
|
| |
| void LogError(string msg, string fnc_name = "n/a") |
| { |
| Debug.LogError(msg, "Object", "n/a", fnc_name, this.GetType()); |
| } |
|
|
| |
| bool IsSkinned() |
| { |
| return GetCompBS() && GetCompBS().IsSkinned(); |
| } |
|
|
| void SetAsSkinned() |
| { |
| if (GetCompBS()) |
| GetCompBS().SetAsSkinned(); |
| } |
|
|
| bool CanBeSkinnedWith(EntityAI tool) |
| { |
| if ( !IsSkinned() && tool ) |
| if ( !IsAlive() ) |
| return true; |
| return false; |
| } |
| |
|
|
| |
| |
| bool HasFlammableMaterial() |
| { |
| return false; |
| } |
| |
| |
| bool CanBeIgnitedBy(EntityAI igniter = NULL) |
| { |
| return false; |
| } |
| |
| |
| bool CanIgniteItem(EntityAI ignite_target = NULL) |
| { |
| return false; |
| } |
| |
| |
| bool IsIgnited() |
| { |
| if (m_EM) |
| return m_EM.IsWorking(); |
| return false; |
| } |
| |
| |
| bool DisassembleOnLastDetach() |
| { |
| return false; |
| } |
| |
| bool IsBasebuildingKit() |
| { |
| return false; |
| } |
| |
| |
| bool PlacementCanBeRotated() |
| { |
| return true; |
| } |
| |
| |
| void OnIgnitedTarget( EntityAI target_item) |
| { |
| |
| } |
| |
| |
| void OnIgnitedThis( EntityAI fire_source) |
| { |
| |
| } |
| |
| |
| void OnIgnitedTargetFailed( EntityAI target_item) |
| { |
| |
| } |
| |
| |
| void OnIgnitedThisFailed( EntityAI fire_source) |
| { |
| |
| } |
| |
| |
| bool IsTargetIgnitionSuccessful(EntityAI item_target) |
| { |
| return true; |
| } |
| |
| |
| bool IsThisIgnitionSuccessful(EntityAI item_source = NULL) |
| { |
| return true; |
| } |
| |
| |
| |
| void OnPlacementStarted(Man player); |
| void OnHologramBeingPlaced(Man player); |
| void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0"); |
| void OnPlacementCancelled(Man player); |
| |
| bool CanBePlaced(Man player, vector position) |
| { |
| return true; |
| } |
|
|
| |
| string CanBePlacedFailMessage( Man player, vector position ) |
| { |
| return ""; |
| } |
| |
| |
| bool DoPlacingHeightCheck() |
| { |
| return false; |
| } |
| |
| |
| float HeightCheckOverride() |
| { |
| return 0.0; |
| } |
| |
| |
| float HeightStartCheckOverride() |
| { |
| return 0.0; |
| } |
| |
| |
| bool IsEmpty() |
| { |
| return (!HasAnyCargo() && GetInventory().AttachmentCount() == 0); |
| } |
| |
| bool CanBeSplit() |
| { |
| return false; |
| } |
|
|
| |
| bool HasAnyCargo() |
| { |
| CargoBase cargo = GetInventory().GetCargo(); |
| |
| if(!cargo) return false; |
| |
| if( cargo.GetItemCount() > 0 ) |
| { |
| return true; |
| } |
| else |
| { |
| return false; |
| } |
| } |
| |
| array<EntityAI> GetAttachmentsWithCargo() |
| { |
| return m_AttachmentsWithCargo; |
| } |
| |
| array<EntityAI> GetAttachmentsWithAttachments() |
| { |
| return m_AttachmentsWithAttachments; |
| } |
|
|
| int GetAgents() { return 0; } |
| void RemoveAgent(int agent_id); |
| void RemoveAllAgents(); |
| void RemoveAllAgentsExcept(int agent_to_keep); |
| void InsertAgent(int agent, float count = 1); |
|
|
| override bool IsEntityAI() { return true; } |
| |
| bool IsInventoryVisible() |
| { |
| return !( GetParent() || GetHierarchyParent() ); |
| } |
| |
| bool IsPlayer() |
| { |
| return false; |
| } |
| |
| bool IsAnimal() |
| { |
| return false; |
| } |
| |
| bool IsZombie() |
| { |
| return false; |
| } |
| |
| bool IsZombieMilitary() |
| { |
| return false; |
| } |
| |
| bool IsIgnoredByConstruction() |
| { |
| return IsDamageDestroyed(); |
| } |
| |
| bool CanBeTargetedByAI(EntityAI ai) |
| { |
| if (ai && ai.IsBeingBackstabbed()) |
| { |
| return false; |
| } |
| |
| if ( !dBodyIsActive( this ) && !IsMan() ) |
| return false; |
| return !IsDamageDestroyed(); |
| } |
| |
| bool CanBeBackstabbed() |
| { |
| return false; |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| override void Delete() |
| { |
| m_PendingDelete = true; |
| super.Delete(); |
| } |
| |
| void DeleteOnClient() |
| { |
| GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(GetGame().ObjectDeleteOnClient, this); |
| } |
| |
| |
| void DeleteSafe() |
| { |
| if (GetHierarchyRootPlayer() == null) |
| { |
| Delete(); |
| } |
| else |
| { |
| if (GetGame().IsServer() && GetGame().IsMultiplayer()) |
| GetHierarchyRootPlayer().JunctureDeleteItem(this); |
| else |
| GetHierarchyRootPlayer().AddItemToDelete(this); |
| } |
| } |
| |
| |
| void DeleteSave() |
| { |
| DeleteSafe(); |
| } |
| |
| bool IsSetForDeletion() |
| { |
| return IsPreparedToDelete() || m_PendingDelete || ToDelete() || IsPendingDeletion(); |
| } |
| |
| override bool CanBeActionTarget() |
| { |
| if (super.CanBeActionTarget()) |
| { |
| return !IsSetForDeletion(); |
| } |
| else |
| { |
| return false; |
| } |
| } |
| |
| void SetPrepareToDelete() |
| { |
| m_PreparedToDelete = true; |
| } |
| |
| bool IsPreparedToDelete() |
| { |
| return m_PreparedToDelete; |
| } |
| |
| |
| void CheckForDestroy() |
| { |
| if (IsPrepareToDelete()) |
| { |
| GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(TryDelete, DELETE_CHECK_DELAY, false); |
| } |
| } |
| |
| bool IsPrepareToDelete() |
| { |
| return false; |
| } |
| |
| bool TryDelete() |
| { |
| if (!IsPrepareToDelete()) |
| { |
| Debug.Log("TryDelete - not ready for deletion"); |
| return false; |
| } |
|
|
| if (GetGame().HasInventoryJunctureItem(this)) |
| { |
| Debug.Log("TryDelete - deferred call"); |
| GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(TryDelete, DELETE_CHECK_DELAY, false); |
| return false; |
| } |
|
|
| OnBeforeTryDelete(); |
| Debug.Log("TryDelete - OnBeforeTryDelete end"); |
| DeleteSafe(); |
| Debug.Log("TryDelete - DeleteSafe end"); |
|
|
| return true; |
| } |
| |
| void OnBeforeTryDelete(); |
| |
| |
| proto native EntityAI GetHierarchyRoot(); |
|
|
| |
| proto native Man GetHierarchyRootPlayer(); |
| |
| |
| proto native EntityAI GetHierarchyParent(); |
|
|
| |
| proto native CEItemProfile GetEconomyProfile(); |
|
|
| |
| int GetHierarchyLevel(int lvl = 0) |
| { |
| if (!GetHierarchyParent()) |
| return lvl; |
|
|
| return GetHierarchyParent().GetHierarchyLevel(lvl+1); |
| } |
| |
| void OnInventoryInit() |
| { |
| InitAttachmentExclusionValues(); |
| } |
| |
| |
| void EEInit() |
| { |
| if (GetInventory()) |
| { |
| GetInventory().EEInit(); |
| m_AttachmentsWithCargo.Clear(); |
| m_AttachmentsWithAttachments.Clear(); |
| for ( int i = 0; i < GetInventory().AttachmentCount(); i++ ) |
| { |
| EntityAI attachment = GetInventory().GetAttachmentFromIndex( i ); |
| if ( attachment ) |
| { |
| if ( attachment.GetInventory().GetCargo() ) |
| { |
| m_AttachmentsWithCargo.Insert( attachment ); |
| } |
| |
| if ( attachment.GetInventory().GetAttachmentSlotsCount() > 0 ) |
| { |
| m_AttachmentsWithAttachments.Insert( attachment ); |
| } |
| } |
| } |
| } |
| |
| MaxLifetimeRefreshCalc(); |
| } |
| |
| |
| void EEDelete(EntityAI parent) |
| { |
| m_PendingDelete = true; |
| GetInventory().EEDelete(parent); |
| |
| if (m_EM) |
| m_EM.OnDeviceDestroyed(); |
| } |
| |
| override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType) |
| { |
| super.OnExplosionEffects(source, directHit, componentIndex, surface, pos, surfNormal, energyFactor, explosionFactor, isWater, ammoType); |
| #ifndef SERVER |
| g_Game.GetWorld().AddEnvShootingSource(pos, 1.0); |
| #endif |
| if (m_DestructionBehaviourObj && m_DestructionBehaviourObj.HasExplosionDamage()) |
| { |
| m_DestructionBehaviourObj.OnExplosionEffects(source, directHit, componentIndex, surface, pos, surfNormal, energyFactor, explosionFactor, isWater, ammoType); |
| } |
| } |
| |
| |
| void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner) { } |
| |
| void OnItemAttachmentSlotChanged (notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc) {} |
| |
| void EEItemLocationChanged (notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc) |
| { |
| EntityAI old_owner = oldLoc.GetParent(); |
| EntityAI new_owner = newLoc.GetParent(); |
| OnItemLocationChanged(old_owner, new_owner); |
| |
| if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT && newLoc.GetType() == InventoryLocationType.ATTACHMENT) |
| { |
| OnItemAttachmentSlotChanged(oldLoc,newLoc); |
| } |
| |
| if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT) |
| { |
| if (old_owner) |
| OnWasDetached(old_owner, oldLoc.GetSlot()); |
| else |
| Error("EntityAI::EEItemLocationChanged - detached, but old_owner is null"); |
| } |
| |
| if (newLoc.GetType() == InventoryLocationType.ATTACHMENT) |
| { |
| if (new_owner) |
| OnWasAttached(newLoc.GetParent(), newLoc.GetSlot()); |
| else |
| Error("EntityAI::EEItemLocationChanged - attached, but new_owner is null"); |
| } |
| } |
|
|
| |
| void EEParentedTo(EntityAI parent) |
| { |
| } |
|
|
| |
| void EEParentedFrom(EntityAI parent) |
| { |
| } |
| |
| void EEInventoryIn (Man newParentMan, EntityAI diz, EntityAI newParent) |
| { |
| } |
| void EEInventoryOut (Man oldParentMan, EntityAI diz, EntityAI newParent) |
| { |
| m_LastUpdatedTime = 0.0; |
| |
| if (GetInventory() && newParent == null) |
| { |
| GetInventory().ResetFlipCargo(); |
| } |
| } |
|
|
| void EEAmmoChanged() |
| { |
| SetWeightDirty(); |
| } |
|
|
| void EEHealthLevelChanged(int oldLevel, int newLevel, string zone) |
| { |
| |
| EntityAI parent = GetHierarchyParent(); |
| |
| if (newLevel == GameConstants.STATE_RUINED) |
| { |
| if (parent) |
| { |
| parent.OnAttachmentRuined(this); |
| } |
| if (!zone) |
| { |
| OnDamageDestroyed(oldLevel); |
| } |
| AttemptDestructionBehaviour(oldLevel,newLevel, zone); |
| } |
| } |
| |
| |
| void OnDamageDestroyed(int oldLevel); |
| |
| void AttemptDestructionBehaviour(int oldLevel, int newLevel, string zone) |
| { |
| if (IsDestructionBehaviour() && GetDestructionBehaviour()) |
| { |
| typename destType = GetDestructionBehaviour().ToType(); |
| |
| if (destType) |
| { |
| if (!m_DestructionBehaviourObj) |
| { |
| m_DestructionBehaviourObj = DestructionEffectBase.Cast(destType.Spawn()); |
| } |
| |
| if (m_DestructionBehaviourObj) |
| { |
| m_DestructionBehaviourObj.OnHealthLevelChanged(this, oldLevel, newLevel, zone); |
| } |
| } |
| else |
| { |
| ErrorEx("Incorrect destruction behaviour type, make sure the class returned in 'GetDestructionBehaviour()' is a valid type inheriting from 'DestructionEffectBase'"); |
| } |
| } |
| } |
| |
| |
| void SetTakeable(bool pState); |
| |
| |
| void EEKilled(Object killer) |
| { |
| if (m_OnKilledInvoker) |
| m_OnKilledInvoker.Invoke(this, killer); |
| |
| GetGame().GetAnalyticsServer().OnEntityKilled( killer, this ); |
| |
| if( ReplaceOnDeath() ) |
| GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( DeathUpdate, DEAD_REPLACE_DELAY, false); |
| } |
| |
| bool ReplaceOnDeath() |
| { |
| return false; |
| } |
| |
| string GetDeadItemName() |
| { |
| return ""; |
| } |
| |
| bool KeepHealthOnReplace() |
| { |
| return false; |
| } |
| |
| void DeathUpdate() |
| { |
| EntityAI dead_entity = EntityAI.Cast( GetGame().CreateObjectEx( GetDeadItemName(), GetPosition(), ECE_OBJECT_SWAP, RF_ORIGINAL ) ); |
| dead_entity.SetOrientation(GetOrientation()); |
| if ( KeepHealthOnReplace() ) |
| dead_entity.SetHealth(GetHealth()); |
| this.Delete(); |
| } |
| |
| |
| void OnAttachmentRuined(EntityAI attachment) |
| { |
| |
| } |
| |
| void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef) |
| { |
| if (m_OnHitByInvoker) |
| m_OnHitByInvoker.Invoke(this, damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef); |
| #ifdef DEVELOPER |
| |
| #endif |
| } |
| |
| |
| void EEHitByRemote(int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos) |
| { |
| |
| } |
| |
| |
| void EEItemAttached(EntityAI item, string slot_name) |
| { |
| int slotId = InventorySlots.GetSlotIdFromString(slot_name); |
| PropagateExclusionValueRecursive(item.GetAttachmentExclusionMaskAll(slotId),slotId); |
| SetWeightDirty(); |
|
|
| if ( m_ComponentsBank != NULL ) |
| { |
| for ( int comp_key = 0; comp_key < COMP_TYPE_COUNT; ++comp_key ) |
| { |
| if ( m_ComponentsBank.IsComponentAlreadyExist(comp_key) ) |
| { |
| m_ComponentsBank.GetComponent(comp_key).Event_OnItemAttached(item, slot_name); |
| } |
| } |
| } |
| |
| |
| if ( m_EM && item.GetCompEM()) |
| m_EM.OnAttachmentAdded(item); |
| |
| if ( item.GetInventory().GetCargo() ) |
| m_AttachmentsWithCargo.Insert( item ); |
| |
| if ( item.GetInventory().GetAttachmentSlotsCount() > 0 ) |
| m_AttachmentsWithAttachments.Insert( item ); |
| |
| if ( m_OnItemAttached ) |
| m_OnItemAttached.Invoke( item, slot_name, this ); |
| } |
| |
| void SwitchItemSelectionTexture(EntityAI item, string slot_name); |
| void SwitchItemSelectionTextureEx(EItemManipulationContext context, Param par = null); |
| |
| |
| void EEItemDetached(EntityAI item, string slot_name) |
| { |
| int slotId = InventorySlots.GetSlotIdFromString(slot_name); |
| ClearExclusionValueRecursive(item.GetAttachmentExclusionMaskAll(slotId),slotId); |
| SetWeightDirty(); |
| |
| if ( m_ComponentsBank != NULL ) |
| { |
| for ( int comp_key = 0; comp_key < COMP_TYPE_COUNT; ++comp_key ) |
| { |
| if ( m_ComponentsBank.IsComponentAlreadyExist(comp_key) ) |
| { |
| m_ComponentsBank.GetComponent(comp_key).Event_OnItemDetached(item, slot_name); |
| } |
| } |
| } |
| |
| |
| if (m_EM && item.GetCompEM()) |
| m_EM.OnAttachmentRemoved(item); |
| |
| if ( m_AttachmentsWithCargo.Find( item ) > -1 ) |
| m_AttachmentsWithCargo.RemoveItem( item ); |
| |
| if ( m_AttachmentsWithAttachments.Find( item ) > -1 ) |
| m_AttachmentsWithAttachments.RemoveItem( item ); |
| |
| |
| if ( m_OnItemDetached ) |
| m_OnItemDetached.Invoke( item, slot_name, this ); |
| } |
|
|
| void EECargoIn(EntityAI item) |
| { |
| SetWeightDirty(); |
| |
| if( m_OnItemAddedIntoCargo ) |
| m_OnItemAddedIntoCargo.Invoke( item, this ); |
| |
| item.OnMovedInsideCargo(this); |
| } |
|
|
| void EECargoOut(EntityAI item) |
| { |
| SetWeightDirty(); |
| |
| if( m_OnItemRemovedFromCargo ) |
| m_OnItemRemovedFromCargo.Invoke( item, this ); |
| |
| item.OnRemovedFromCargo(this); |
| } |
|
|
| void EECargoMove(EntityAI item) |
| { |
| if( m_OnItemMovedInCargo ) |
| m_OnItemMovedInCargo.Invoke( item, this ); |
| item.OnMovedWithinCargo(this); |
| } |
| |
| ScriptInvoker GetOnItemAttached() |
| { |
| if( !m_OnItemAttached ) |
| m_OnItemAttached = new ScriptInvoker; |
| return m_OnItemAttached; |
| } |
| |
| ScriptInvoker GetOnItemDetached() |
| { |
| if( !m_OnItemDetached ) |
| m_OnItemDetached = new ScriptInvoker; |
| return m_OnItemDetached; |
| } |
| |
| ScriptInvoker GetOnItemAddedIntoCargo() |
| { |
| if( !m_OnItemAddedIntoCargo ) |
| m_OnItemAddedIntoCargo = new ScriptInvoker; |
| return m_OnItemAddedIntoCargo; |
| } |
| |
| ScriptInvoker GetOnItemRemovedFromCargo() |
| { |
| if( !m_OnItemRemovedFromCargo ) |
| m_OnItemRemovedFromCargo = new ScriptInvoker; |
| return m_OnItemRemovedFromCargo; |
| } |
| |
| ScriptInvoker GetOnItemMovedInCargo() |
| { |
| if( !m_OnItemMovedInCargo ) |
| m_OnItemMovedInCargo = new ScriptInvoker; |
| return m_OnItemMovedInCargo; |
| } |
| |
| ScriptInvoker GetOnItemFlipped() |
| { |
| if( !m_OnItemFlipped ) |
| m_OnItemFlipped = new ScriptInvoker; |
| return m_OnItemFlipped; |
| } |
| |
| ScriptInvoker GetOnViewIndexChanged() |
| { |
| if( !m_OnViewIndexChanged ) |
| m_OnViewIndexChanged = new ScriptInvoker; |
| return m_OnViewIndexChanged; |
| } |
| |
| ScriptInvoker GetOnSetLock() |
| { |
| if( !m_OnSetLock ) |
| m_OnSetLock = new ScriptInvoker; |
| return m_OnSetLock; |
| } |
| |
| ScriptInvoker GetOnReleaseLock() |
| { |
| if( !m_OnReleaseLock ) |
| m_OnReleaseLock = new ScriptInvoker; |
| return m_OnReleaseLock; |
| } |
| |
| ScriptInvoker GetOnAttachmentSetLock() |
| { |
| if( !m_OnAttachmentSetLock ) |
| m_OnAttachmentSetLock = new ScriptInvoker; |
| return m_OnAttachmentSetLock; |
| } |
| |
| ScriptInvoker GetOnAttachmentReleaseLock() |
| { |
| if( !m_OnAttachmentReleaseLock ) |
| m_OnAttachmentReleaseLock = new ScriptInvoker; |
| return m_OnAttachmentReleaseLock; |
| } |
| |
| ScriptInvoker GetOnHitByInvoker() |
| { |
| if ( !m_OnHitByInvoker ) |
| m_OnHitByInvoker = new ScriptInvoker; |
| return m_OnHitByInvoker; |
| } |
| |
| ScriptInvoker GetOnKilledInvoker() |
| { |
| if ( !m_OnKilledInvoker ) |
| m_OnKilledInvoker = new ScriptInvoker; |
| return m_OnKilledInvoker; |
| } |
| |
| |
| |
| void OnMovedInsideCargo(EntityAI container) |
| { |
| if (m_EM) |
| m_EM.HandleMoveInsideCargo(container); |
| } |
| |
| |
| void OnRemovedFromCargo(EntityAI container) |
| { |
| |
| } |
| |
| |
| void OnMovedWithinCargo(EntityAI container) |
| { |
| |
| } |
| |
| |
| void EEOnAfterLoad() |
| { |
| |
| |
| if ( m_EM && m_EM.GetRestorePlugState() ) |
| { |
| int b1 = m_EM.GetEnergySourceStorageIDb1(); |
| int b2 = m_EM.GetEnergySourceStorageIDb2(); |
| int b3 = m_EM.GetEnergySourceStorageIDb3(); |
| int b4 = m_EM.GetEnergySourceStorageIDb4(); |
|
|
| |
| EntityAI potential_energy_source = GetGame().GetEntityByPersitentID(b1, b2, b3, b4); |
| |
| |
| |
| |
| |
| |
| bool is_attachment = false; |
| |
| if (potential_energy_source) |
| is_attachment = GetInventory().HasAttachment(potential_energy_source); |
| |
| if ( !is_attachment && potential_energy_source ) |
| is_attachment = potential_energy_source.GetInventory().HasAttachment(this); |
| |
| if ( potential_energy_source && potential_energy_source.GetCompEM() && !is_attachment ) |
| m_EM.PlugThisInto(potential_energy_source); |
| } |
| } |
| |
| |
| void EEOnCECreate() |
| { |
| } |
|
|
| |
| void AfterStoreLoad() |
| { |
| } |
| |
| |
| void OnBinLoadItemsDropped() |
| { |
| if (GetHierarchyRootPlayer()) |
| GetHierarchyRootPlayer().SetProcessUIWarning(true); |
| } |
| |
| |
| void HideAllSelections() |
| { |
| string cfg_path = "cfgVehicles " + GetType() + " AnimationSources"; |
| |
| if ( GetGame().ConfigIsExisting(cfg_path) ) |
| { |
| int selections = GetGame().ConfigGetChildrenCount(cfg_path); |
| |
| for (int i = 0; i < selections; i++) |
| { |
| string selection_name; |
| GetGame().ConfigGetChildName(cfg_path, i, selection_name); |
| HideSelection(selection_name); |
| } |
| } |
| } |
| |
| |
| void ShowAllSelections() |
| { |
| string cfg_path = "cfgVehicles " + GetType() + " AnimationSources"; |
| |
| if ( GetGame().ConfigIsExisting(cfg_path) ) |
| { |
| int selections = GetGame().ConfigGetChildrenCount(cfg_path); |
| |
| for (int i = 0; i < selections; i++) |
| { |
| string selection_name; |
| GetGame().ConfigGetChildName(cfg_path, i, selection_name); |
| ShowSelection(selection_name); |
| } |
| } |
| } |
| |
| |
| |
| |
| |
| |
| |
| bool CanReceiveAttachment (EntityAI attachment, int slotId) |
| { |
| |
| EntityAI currentAtt = GetInventory().FindAttachment(slotId); |
| bool hasInternalConflict = attachment.HasInternalExclusionConflicts(slotId); |
| if (currentAtt) |
| { |
| set<int> diff = attachment.GetAttachmentExclusionMaskAll(slotId); |
| diff.RemoveItems(currentAtt.GetAttachmentExclusionMaskAll(slotId)); |
| if (diff.Count() == 0) |
| { |
| return !hasInternalConflict; |
| } |
| else |
| { |
| return !hasInternalConflict && !IsExclusionFlagPresentRecursive(diff,slotId); |
| } |
| } |
| return !hasInternalConflict && !IsExclusionFlagPresentRecursive(attachment.GetAttachmentExclusionMaskAll(slotId),slotId); |
| } |
| |
| |
| |
| |
| |
| |
| |
| bool CanLoadAttachment(EntityAI attachment) |
| { |
| return true; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| bool CanPutAsAttachment (EntityAI parent) |
| { |
| return !IsHologram(); |
| } |
|
|
| |
| bool CanSwitchDuringAttach(EntityAI parent) |
| { |
| return false; |
| } |
| |
| |
| |
| |
| |
| |
| bool CanReleaseAttachment (EntityAI attachment) |
| { |
| if( attachment && attachment.GetInventory() && GetInventory() ) |
| { |
| InventoryLocation il = new InventoryLocation(); |
| attachment.GetInventory().GetCurrentInventoryLocation( il ); |
| if( il.IsValid() ) |
| { |
| int slot = il.GetSlot(); |
| return !GetInventory().GetSlotLock( slot ); |
| } |
| } |
| return true; |
| } |
| |
| |
| |
| |
| |
| |
| bool CanDetachAttachment (EntityAI parent) |
| { |
| return true; |
| } |
| |
| bool CanBeFSwaped() |
| { |
| return true; |
| } |
| |
| bool CanCombineAttachment(notnull EntityAI e, int slot, bool stack_max_limit = false) |
| { |
| EntityAI att = GetInventory().FindAttachment(slot); |
| if(att) |
| return att.CanBeCombined(e, true, stack_max_limit); |
| return false; |
| } |
| |
| bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false ) |
| { |
| return false; |
| } |
| |
| void CombineItemsClient(EntityAI entity2, bool use_stack_max = false ) |
| {} |
| |
| |
| |
| |
| |
| |
| |
| bool CanReceiveItemIntoCargo(EntityAI item) |
| { |
| if (GetInventory() && GetInventory().GetCargo()) |
| return GetInventory().GetCargo().CanReceiveItemIntoCargo(item)); |
| |
| return true; |
| } |
| |
| |
| |
| |
| |
| |
| |
| bool CanLoadItemIntoCargo(EntityAI item) |
| { |
| return true; |
| } |
| |
| |
| |
| |
| |
| |
| |
| bool CanPutInCargo (EntityAI parent) |
| { |
| return !IsHologram(); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| bool CanSwapItemInCargo (EntityAI child_entity, EntityAI new_entity) |
| { |
| if (GetInventory() && GetInventory().GetCargo()) |
| return GetInventory().GetCargo().CanSwapItemInCargo(child_entity, new_entity)); |
| |
| return true; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| bool CanReleaseCargo (EntityAI cargo) |
| { |
| return true; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| bool CanRemoveFromCargo (EntityAI parent) |
| { |
| return true; |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| bool CanReceiveItemIntoHands (EntityAI item_to_hands) |
| { |
| return true; |
| } |
| |
| bool IsBeingPlaced() |
| { |
| return false; |
| } |
| |
| override bool IsHologram() |
| { |
| return false; |
| } |
| |
| bool CanSaveItemInHands (EntityAI item_in_hands) |
| { |
| return true; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| bool CanPutIntoHands (EntityAI parent) |
| { |
| return !IsHologram(); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| bool CanReleaseFromHands (EntityAI handheld) |
| { |
| return true; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| bool CanRemoveFromHands (EntityAI parent) |
| { |
| return true; |
| } |
|
|
| |
| |
| |
| |
| bool CanDisplayAttachmentSlot( string slot_name ) |
| { |
| Debug.LogWarning("Obsolete function - use CanDisplayAttachmentSlot with slot id parameter"); |
| return InventorySlots.GetShowForSlotId(InventorySlots.GetSlotIdFromString(slot_name)); |
| } |
| |
| |
| |
| |
| |
| bool CanDisplayAttachmentSlot( int slot_id ) |
| { |
| return InventorySlots.GetShowForSlotId(slot_id); |
| } |
| |
| |
| |
| |
| bool CanDisplayAnyAttachmentSlot() |
| { |
| int count = GetInventory().GetAttachmentSlotsCount(); |
| int slotID; |
| for (int i = 0; i < count; i++) |
| { |
| slotID = GetInventory().GetAttachmentSlotId(i); |
| if (CanDisplayAttachmentSlot(slotID)) |
| { |
| return true; |
| } |
| } |
| |
| return false; |
| } |
|
|
| |
| |
| |
| |
| bool CanDisplayAttachmentCategory( string category_name ) |
| { |
| return true; |
| } |
| |
| |
| |
| |
| bool CanDisplayCargo() |
| { |
| return GetInventory().GetCargo() != null; |
| } |
| |
| |
| |
| |
| bool CanAssignToQuickbar() |
| { |
| return true; |
| } |
| |
| |
| |
| |
| bool CanAssignAttachmentsToQuickbar() |
| { |
| return true; |
| } |
| |
| |
| |
| |
| bool IgnoreOutOfReachCondition() |
| { |
| return GetHierarchyRootPlayer() == GetGame().GetPlayer(); |
| } |
|
|
| |
| void OnWasAttached( EntityAI parent, int slot_id ); |
| |
| |
| void OnWasDetached( EntityAI parent, int slot_id ) |
| { |
| if (!IsFlagSet(EntityFlags.VISIBLE)) |
| { |
| SetInvisible(false); |
| OnInvisibleSet(false); |
| SetInvisibleRecursive(false,parent); |
| } |
| } |
| |
| void OnCargoChanged() { } |
| |
| bool IsTakeable() |
| { |
| return false; |
| } |
| |
| proto native GameInventory GetInventory(); |
| proto native void CreateAndInitInventory(); |
| proto native void DestroyInventory(); |
| |
| int GetSlotsCountCorrect() |
| { |
| if (GetInventory()) |
| return GetInventory().GetAttachmentSlotsCount(); |
| else |
| return -1; |
| } |
|
|
| EntityAI FindAttachmentBySlotName(string slot_name) |
| { |
| if ( GetGame() ) |
| { |
| int slot_id = InventorySlots.GetSlotIdFromString(slot_name); |
| if (slot_id != InventorySlots.INVALID) |
| return GetInventory().FindAttachment(slot_id); |
| } |
| return null; |
| } |
|
|
| |
| |
| |
| bool IsLockedInSlot() |
| { |
| EntityAI parent = GetHierarchyParent(); |
| if ( parent ) |
| { |
| InventoryLocation inventory_location = new InventoryLocation(); |
| GetInventory().GetCurrentInventoryLocation( inventory_location ); |
| |
| return parent.GetInventory().GetSlotLock( inventory_location.GetSlot() ); |
| } |
| |
| return false; |
| } |
| |
| |
| |
| |
| bool PredictiveTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item) |
| { |
| if ( GetGame().IsMultiplayer() ) |
| return GetInventory().TakeEntityToInventory(InventoryMode.JUNCTURE, flags, item); |
| else |
| return GetInventory().TakeEntityToInventory(InventoryMode.PREDICTIVE, flags, item); |
| } |
| bool LocalTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item) |
| { |
| return GetInventory().TakeEntityToInventory(InventoryMode.LOCAL, flags, item); |
| } |
| bool ServerTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item) |
| { |
| return GetInventory().TakeEntityToInventory(InventoryMode.SERVER, flags, item); |
| } |
| bool PredictiveTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item) |
| { |
| if ( GetGame().IsMultiplayer() ) |
| return GetInventory().TakeEntityToTargetInventory(InventoryMode.JUNCTURE, target, flags, item); |
| else |
| return GetInventory().TakeEntityToTargetInventory(InventoryMode.PREDICTIVE, target, flags, item); |
| } |
| bool LocalTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item) |
| { |
| return GetInventory().TakeEntityToTargetInventory(InventoryMode.LOCAL, target, flags, item); |
| } |
| bool ServerTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item) |
| { |
| return GetInventory().TakeEntityToTargetInventory(InventoryMode.SERVER, target, flags, item); |
| } |
| |
| |
| |
| bool PredictiveTakeEntityToCargo (notnull EntityAI item) |
| { |
| if ( GetGame().IsMultiplayer() ) |
| return GetInventory().TakeEntityToCargo(InventoryMode.JUNCTURE, item); |
| else |
| return GetInventory().TakeEntityToCargo(InventoryMode.PREDICTIVE, item); |
| } |
| bool LocalTakeEntityToCargo (notnull EntityAI item) |
| { |
| return GetInventory().TakeEntityToCargo(InventoryMode.LOCAL, item); |
| } |
| bool ServerTakeEntityToCargo (notnull EntityAI item) |
| { |
| return GetInventory().TakeEntityToCargo(InventoryMode.SERVER, item); |
| } |
|
|
| bool PredictiveTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item) |
| { |
| if ( GetGame().IsMultiplayer() ) |
| return GetInventory().TakeEntityToTargetCargo(InventoryMode.JUNCTURE, target, item); |
| else |
| return GetInventory().TakeEntityToTargetCargo(InventoryMode.PREDICTIVE, target, item); |
| } |
| bool LocalTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item) |
| { |
| return GetInventory().TakeEntityToTargetCargo(InventoryMode.LOCAL, target, item); |
| } |
| bool ServerTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item) |
| { |
| return GetInventory().TakeEntityToTargetCargo(InventoryMode.SERVER, target, item); |
| } |
| |
| |
| |
| bool PredictiveTakeEntityToCargoEx (notnull EntityAI item, int idx, int row, int col) |
| { |
| if ( GetGame().IsMultiplayer() ) |
| return GetInventory().TakeEntityToCargoEx(InventoryMode.JUNCTURE, item, idx, row, col); |
| else |
| return GetInventory().TakeEntityToCargoEx(InventoryMode.PREDICTIVE, item, idx, row, col); |
| } |
| bool LocalTakeEntityToCargoEx (notnull EntityAI item, int idx, int row, int col) |
| { |
| return GetInventory().TakeEntityToCargoEx(InventoryMode.LOCAL, item, idx, row, col); |
| } |
|
|
| bool PredictiveTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col) |
| { |
| if ( GetGame().IsMultiplayer() ) |
| return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.JUNCTURE, cargo, item, row, col); |
| else |
| return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.PREDICTIVE, cargo, item, row, col); |
| } |
| bool LocalTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col) |
| { |
| return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.LOCAL, cargo, item, row, col); |
| } |
| bool ServerTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col) |
| { |
| return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.SERVER, cargo, item, row, col); |
| } |
| |
| |
| |
| bool PredictiveTakeEntityAsAttachmentEx (notnull EntityAI item, int slot) |
| { |
| if ( GetGame().IsMultiplayer() ) |
| return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.JUNCTURE, item, slot); |
| else |
| return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.PREDICTIVE, item, slot); |
| } |
| bool LocalTakeEntityAsAttachmentEx (notnull EntityAI item, int slot) |
| { |
| return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.LOCAL, item, slot); |
| } |
| bool ServerTakeEntityAsAttachmentEx (notnull EntityAI item, int slot) |
| { |
| return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.SERVER, item, slot); |
| } |
|
|
| bool PredictiveTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot) |
| { |
| if ( GetGame().IsMultiplayer() ) |
| return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.JUNCTURE, target, item, slot); |
| else |
| return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.PREDICTIVE, target, item, slot); |
| } |
| bool LocalTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot) |
| { |
| return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.LOCAL, target, item, slot); |
| } |
| bool ServerTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot) |
| { |
| return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.SERVER, target, item, slot); |
| } |
|
|
| bool PredictiveTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item) |
| { |
| if ( GetGame().IsMultiplayer() ) |
| return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.JUNCTURE, target, item); |
| else |
| return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.PREDICTIVE, target, item); |
| } |
| bool LocalTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item) |
| { |
| return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.LOCAL, target, item); |
| } |
| bool ServerTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item) |
| { |
| return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.SERVER, target, item); |
| } |
|
|
| bool PredictiveTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst) |
| { |
| if ( GetGame().IsMultiplayer() ) |
| return GetInventory().TakeToDst(InventoryMode.JUNCTURE, src, dst); |
| else |
| return GetInventory().TakeToDst(InventoryMode.PREDICTIVE, src, dst); |
| } |
| bool LocalTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst) |
| { |
| return GetInventory().TakeToDst(InventoryMode.LOCAL, src, dst); |
| } |
| bool ServerTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst) |
| { |
| return GetInventory().TakeToDst(InventoryMode.SERVER, src, dst); |
| } |
|
|
| |
| |
| |
| bool PredictiveTakeEntityAsAttachment(notnull EntityAI item) |
| { |
| if (GetGame().IsMultiplayer()) |
| return GetInventory().TakeEntityAsAttachment(InventoryMode.JUNCTURE, item); |
| else |
| return GetInventory().TakeEntityAsAttachment(InventoryMode.PREDICTIVE, item); |
| } |
| bool LocalTakeEntityAsAttachment (notnull EntityAI item) |
| { |
| return GetInventory().TakeEntityAsAttachment(InventoryMode.LOCAL, item); |
| } |
| bool ServerTakeEntityAsAttachment (notnull EntityAI item) |
| { |
| return GetInventory().TakeEntityAsAttachment(InventoryMode.SERVER, item); |
| } |
|
|
| bool PredictiveDropEntity(notnull EntityAI item) |
| { |
| return false; |
| } |
| |
| bool LocalDropEntity(notnull EntityAI item) |
| { |
| return false; |
| } |
| |
| bool ServerDropEntity(notnull EntityAI item) |
| { |
| return false; |
| } |
|
|
| |
| |
| |
| EntityAI GetAttachmentByType(typename type) |
| { |
| for ( int i = 0; i < GetInventory().AttachmentCount(); i++ ) |
| { |
| EntityAI attachment = GetInventory().GetAttachmentFromIndex( i ); |
| if ( attachment && attachment.IsInherited( type ) ) |
| return attachment; |
| } |
| return NULL; |
| } |
|
|
| |
| |
| |
| EntityAI GetAttachmentByConfigTypeName(string type) |
| { |
| for ( int i = 0; i < GetInventory().AttachmentCount(); i++ ) |
| { |
| EntityAI attachment = GetInventory().GetAttachmentFromIndex ( i ); |
| if ( attachment.IsKindOf ( type ) ) |
| return attachment; |
| } |
| return NULL; |
| } |
| |
| |
| |
| bool CanDropEntity(notnull EntityAI item) |
| { |
| return true; |
| } |
|
|
| EntityAI SpawnInInventoryOrGroundPos(string object_name, GameInventory inv, vector pos) |
| { |
| if (inv) |
| { |
| EntityAI res = inv.CreateInInventory(object_name); |
| if (res) |
| { |
| return res; |
| } |
| } |
|
|
| return SpawnEntityOnGroundPos(object_name, pos); |
| } |
|
|
| |
| |
| EntityAI SpawnEntityOnGroundPos(string object_name, vector pos) |
| { |
| InventoryLocation il = new InventoryLocation(); |
| vector mat[4]; |
| Math3D.MatrixIdentity4(mat); |
| mat[3] = pos; |
| il.SetGround(NULL, mat); |
| return SpawnEntity(object_name, il,ECE_PLACE_ON_SURFACE,RF_DEFAULT); |
| } |
| |
| |
| EntityAI SpawnEntityOnGround(string object_name, vector mat[4]) |
| { |
| InventoryLocation il = new InventoryLocation(); |
| il.SetGround(NULL, mat); |
| return SpawnEntity(object_name, il,ECE_PLACE_ON_SURFACE,RF_DEFAULT); |
| } |
| |
| |
|
|
| bool CanSwapEntities(EntityAI otherItem, InventoryLocation otherDestination, InventoryLocation destination) |
| { |
| return true; |
| } |
| |
| |
| |
| void SetWet(float value, bool allow_client = false); |
| void AddWet(float value); |
| void SetWetMax(); |
|
|
| float GetWet() |
| { |
| return 0; |
| } |
| |
| float GetWetMax() |
| { |
| return 0; |
| } |
|
|
| float GetWetMin() |
| { |
| return 0; |
| } |
| |
| float GetWetInit() |
| { |
| return 0; |
| } |
| |
| bool HasWetness() |
| { |
| return GetWetMax() - GetWetMin() != 0; |
| } |
| |
| void OnWetChanged(float newVal, float oldVal); |
|
|
| void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel); |
| |
| EWetnessLevel GetWetLevel(); |
| |
| |
| static EWetnessLevel GetWetLevelInternal(float wetness) |
| { |
| if (wetness < GameConstants.STATE_DAMP) |
| { |
| return EWetnessLevel.DRY; |
| } |
| else if (wetness < GameConstants.STATE_WET) |
| { |
| return EWetnessLevel.DAMP; |
| } |
| else if (wetness < GameConstants.STATE_SOAKING_WET) |
| { |
| return EWetnessLevel.WET; |
| } |
| else if (wetness < GameConstants.STATE_DRENCHED) |
| { |
| return EWetnessLevel.SOAKING; |
| } |
| return EWetnessLevel.DRENCHED; |
| } |
| |
| |
| float GetQuantity() |
| { |
| return 0; |
| } |
| |
| int GetQuantityMax() |
| { |
| return 0; |
| } |
| |
| void SetQuantityToMinimum(); |
| |
| int GetTargetQuantityMax(int attSlotID = -1) |
| { |
| return 0; |
| } |
| |
| int GetQuickBarBonus() |
| { |
| return 0; |
| } |
|
|
| |
|
|
| void SetTemperature(float value, bool allow_client = false) {}; |
| void AddTemperature(float value) {}; |
| void SetTemperatureMax() {}; |
|
|
| float GetTemperature() |
| { |
| return 0; |
| } |
| |
| float GetTemperatureInit() |
| { |
| return 0; |
| } |
| |
| float GetTemperatureMin() |
| { |
| return 0; |
| } |
|
|
| float GetTemperatureMax() |
| { |
| return 0; |
| } |
| |
| |
| |
| HiddenSelectionsData GetHiddenSelectionsData() |
| { |
| return m_HiddenSelectionsData; |
| } |
| |
| |
| int GetHiddenSelectionIndex( string selection ) |
| { |
| if (m_HiddenSelectionsData) |
| return m_HiddenSelectionsData.GetHiddenSelectionIndex( selection ); |
|
|
| return -1; |
| } |
| |
| |
| override TStringArray GetHiddenSelections() |
| { |
| if (m_HiddenSelectionsData) |
| return m_HiddenSelectionsData.m_HiddenSelections; |
| else |
| return super.GetHiddenSelections(); |
| } |
| |
| |
| override TStringArray GetHiddenSelectionsTextures() |
| { |
| if (m_HiddenSelectionsData) |
| return m_HiddenSelectionsData.m_HiddenSelectionsTextures; |
| else |
| return super.GetHiddenSelectionsTextures(); |
| } |
| |
| |
| override TStringArray GetHiddenSelectionsMaterials() |
| { |
| if (m_HiddenSelectionsData) |
| return m_HiddenSelectionsData.m_HiddenSelectionsMaterials; |
| else |
| return super.GetHiddenSelectionsMaterials(); |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| proto native void PlaceOnSurfaceRotated(out vector trans[4], vector pos, float dx = 0, float dz = 0, float fAngle = 0, bool align = false); |
|
|
| |
| |
| |
| |
| |
| |
| proto native void RegisterNetSyncVariableBool(string variableName); |
| |
| |
| |
| |
| |
| |
| |
| proto native void RegisterNetSyncVariableBoolSignal(string variableName); |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| proto native void RegisterNetSyncVariableInt(string variableName, int minValue = 0, int maxValue = 0); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| proto native void RegisterNetSyncVariableFloat(string variableName, float minValue = 0, float maxValue = 0, int precision = 1); |
| |
| |
| |
| |
| |
| |
| |
| proto native void RegisterNetSyncVariableObject(string variableName); |
| |
| proto native void UpdateNetSyncVariableInt(string variableName, float minValue = 0, float maxValue = 0); |
| proto native void UpdateNetSyncVariableFloat(string variableName, float minValue = 0, float maxValue = 0, int precision = 1); |
|
|
| proto native void SwitchLight(bool isOn); |
|
|
| |
| proto native void SetSimpleHiddenSelectionState(int index, bool state); |
| proto native bool IsSimpleHiddenSelectionVisible(int index); |
| |
| |
| proto native void SetObjectTexture(int index, string texture_name); |
| proto native owned string GetObjectTexture(int index); |
| |
| proto native void SetObjectMaterial(int index, string mat_name); |
| proto native owned string GetObjectMaterial(int index); |
| |
| proto native bool IsPilotLight(); |
| proto native void SetPilotLight(bool isOn); |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| void OnStoreSave(ParamsWriteContext ctx) |
| { |
| |
| if ( m_EM ) |
| { |
| |
| ctx.Write( m_EM.GetEnergy() ); |
| |
| |
| ctx.Write( m_EM.IsPassive() ); |
| |
| |
| ctx.Write( m_EM.IsSwitchedOn() ); |
| |
| |
| ctx.Write( m_EM.IsPlugged() ); |
| |
| |
| |
| EntityAI energy_source = m_EM.GetEnergySource(); |
| int b1 = 0; |
| int b2 = 0; |
| int b3 = 0; |
| int b4 = 0; |
|
|
| if (energy_source) |
| { |
| energy_source.GetPersistentID(b1, b2, b3, b4); |
| } |
|
|
| ctx.Write( b1 ); |
| ctx.Write( b2 ); |
| ctx.Write( b3 ); |
| ctx.Write( b4 ); |
| } |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| bool OnStoreLoad (ParamsReadContext ctx, int version) |
| { |
| |
| |
| if ( m_EM ) |
| { |
| |
| float f_energy = 0; |
| if ( !ctx.Read( f_energy ) ) |
| f_energy = 0; |
| m_EM.SetEnergy(f_energy); |
| |
| |
| bool b_is_passive = false; |
| if ( !ctx.Read( b_is_passive ) ) |
| return false; |
| m_EM.SetPassiveState(b_is_passive); |
| |
| |
| bool b_is_on = false; |
| if ( !ctx.Read( b_is_on ) ) |
| { |
| m_EM.SwitchOn(); |
| return false; |
| } |
| |
| |
| bool b_is_plugged = false; |
| if ( !ctx.Read( b_is_plugged ) ) |
| return false; |
| |
| |
| if ( version <= 103 ) |
| { |
| |
| int i_energy_source_ID_low = 0; |
| if ( !ctx.Read( i_energy_source_ID_low ) ) |
| return false; |
| |
| |
| int i_energy_source_ID_high = 0; |
| if ( !ctx.Read( i_energy_source_ID_high ) ) |
| return false; |
| } |
| else |
| { |
| int b1 = 0; |
| int b2 = 0; |
| int b3 = 0; |
| int b4 = 0; |
|
|
| if ( !ctx.Read(b1) ) return false; |
| if ( !ctx.Read(b2) ) return false; |
| if ( !ctx.Read(b3) ) return false; |
| if ( !ctx.Read(b4) ) return false; |
|
|
| if ( b_is_plugged ) |
| { |
| |
| m_EM.StoreEnergySourceIDs( b1, b2, b3, b4 ); |
| m_EM.RestorePlugState(true); |
| } |
| } |
|
|
| if (b_is_on) |
| { |
| m_EM.SwitchOn(); |
| } |
| } |
| return true; |
| } |
|
|
| |
| proto native void SetSynchDirty(); |
|
|
| |
| |
| |
| void OnVariablesSynchronized() |
| { |
| if ( m_EM ) |
| { |
| if ( GetGame().IsMultiplayer() ) |
| { |
| bool is_on = m_EM.IsSwitchedOn(); |
| |
| if (is_on != m_EM.GetPreviousSwitchState()) |
| { |
| if (is_on) |
| m_EM.SwitchOn(); |
| else |
| m_EM.SwitchOff(); |
| } |
| |
| int id_low = m_EM.GetEnergySourceNetworkIDLow(); |
| int id_High = m_EM.GetEnergySourceNetworkIDHigh(); |
| |
| EntityAI energy_source = EntityAI.Cast( GetGame().GetObjectByNetworkId(id_low, id_High) ); |
| |
| if (energy_source) |
| { |
| ComponentEnergyManager esem = energy_source.GetCompEM(); |
| |
| if ( !esem ) |
| { |
| string object = energy_source.GetType(); |
| Error("Synchronization error! Object " + object + " has no instance of the Energy Manager component!"); |
| } |
| |
| m_EM.PlugThisInto(energy_source); |
| |
| } |
| else |
| { |
| m_EM.UnplugThis(); |
| } |
| |
| m_EM.DeviceUpdate(); |
| m_EM.StartUpdates(); |
| } |
| } |
| } |
|
|
| proto native void SetAITargetCallbacks(AbstractAITargetCallbacks callbacks); |
|
|
| override void EOnFrame(IEntity other, float timeSlice) |
| { |
| if ( m_ComponentsBank != NULL ) |
| { |
| for ( int comp_key = 0; comp_key < COMP_TYPE_COUNT; ++comp_key ) |
| { |
| if ( m_ComponentsBank.IsComponentAlreadyExist(comp_key) ) |
| { |
| m_ComponentsBank.GetComponent(comp_key).Event_OnFrame(other, timeSlice); |
| } |
| } |
| } |
| } |
| |
| string GetDebugText() |
| { |
| string text = string.Empty; |
|
|
| text += "Weight: " + GetWeightEx() + "\n"; |
| text += "Disabled: " + GetIsSimulationDisabled() + "\n"; |
| #ifdef SERVER |
| if (GetEconomyProfile()) |
| text += "CE Lifetime default: " + (int)GetEconomyProfile().GetLifetime() + "\n"; |
| text += "CE Lifetime remaining: " + (int)GetLifetime() + "\n"; |
| #endif |
| |
| ComponentEnergyManager compEM = GetCompEM(); |
| if (compEM) |
| { |
| text += "Energy Source: " + Object.GetDebugName(compEM.GetEnergySource()) + "\n"; |
| text += "Switched On: " + compEM.IsSwitchedOn() + "\n"; |
| text += "Is Working: " + compEM.IsWorking() + "\n"; |
| } |
|
|
| return text; |
| } |
| |
| |
| void GetDebugButtonNames(out string button1, out string button2, out string button3, out string button4){} |
| void OnDebugButtonPressClient(int button_index){} |
| void OnDebugButtonPressServer(int button_index){} |
| |
| |
| Shape DebugBBoxDraw() |
| { |
| return GetComponent(COMP_TYPE_ETITY_DEBUG).DebugBBoxDraw(); |
| } |
|
|
| void DebugBBoxSetColor(int color) |
| { |
| GetComponent(COMP_TYPE_ETITY_DEBUG).DebugBBoxSetColor(color); |
| } |
|
|
| void DebugBBoxDelete() |
| { |
| GetComponent(COMP_TYPE_ETITY_DEBUG).DebugBBoxDelete(); |
| } |
|
|
| Shape DebugDirectionDraw(float distance = 1) |
| { |
| return GetComponent(COMP_TYPE_ETITY_DEBUG).DebugDirectionDraw(distance); |
| } |
|
|
| void DebugDirectionSetColor(int color) |
| { |
| GetComponent(COMP_TYPE_ETITY_DEBUG).DebugDirectionSetColor(color); |
| } |
|
|
| void DebugDirectionDelete() |
| { |
| GetComponent(COMP_TYPE_ETITY_DEBUG).DebugDirectionDelete(); |
| } |
|
|
| |
| void HideSelection( string selection_name ) |
| { |
| if ( !ToDelete() ) |
| { |
| SetAnimationPhase ( selection_name, 1 ); |
| } |
| } |
|
|
| |
| void ShowSelection( string selection_name ) |
| { |
| if ( !ToDelete() ) |
| { |
| SetAnimationPhase ( selection_name, 0 ); |
| } |
| } |
|
|
| |
| |
| proto void GetPersistentID( out int b1, out int b2, out int b3, out int b4 ); |
|
|
| |
| proto native void SetLifetime( float fLifeTime ); |
| |
| proto native float GetLifetime(); |
| |
| proto native void IncreaseLifetime(); |
|
|
| |
| proto native void SetLifetimeMax( float fLifeTime ); |
| |
| proto native float GetLifetimeMax(); |
|
|
| |
| void IncreaseLifetimeUp() |
| { |
| IncreaseLifetime(); |
| if (GetHierarchyParent()) |
| GetHierarchyParent().IncreaseLifetimeUp(); |
| } |
|
|
|
|
| |
| |
| ComponentBodyStaging GetCompBS() |
| { |
| if ( HasComponent(COMP_TYPE_BODY_STAGING) ) |
| return ComponentBodyStaging.Cast( GetComponent(COMP_TYPE_BODY_STAGING) ); |
| return NULL; |
| } |
|
|
| |
| |
| |
| ComponentEnergyManager GetCompEM() |
| { |
| if (m_EM) |
| return m_EM; |
| |
| if ( HasComponent(COMP_TYPE_ENERGY_MANAGER) ) |
| return ComponentEnergyManager.Cast( GetComponent(COMP_TYPE_ENERGY_MANAGER) ); |
| return NULL; |
| } |
|
|
| |
| bool HasEnergyManager() |
| { |
| return HasComponent(COMP_TYPE_ENERGY_MANAGER); |
| } |
|
|
| |
|
|
| |
| void OnWorkStart() {} |
|
|
| |
| void OnWork( float consumed_energy ) {} |
|
|
| |
| void OnWorkStop() {} |
|
|
| |
| void OnSwitchOn() {} |
|
|
| |
| void OnSwitchOff() {} |
|
|
| |
| void OnIsPlugged(EntityAI source_device) {} |
|
|
| |
| void OnIsUnplugged( EntityAI last_energy_source ) {} |
|
|
| |
| void OnOwnSocketTaken( EntityAI device ) {} |
|
|
| |
| void OnOwnSocketReleased( EntityAI device ) {} |
|
|
| |
| void OnInitEnergy() {} |
|
|
| |
| void OnEnergyConsumed() {} |
|
|
| |
| void OnEnergyAdded() {} |
| |
| |
| override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx) |
| { |
| super.OnRPC(sender, rpc_type, ctx); |
|
|
| if ( GetGame().IsClient() ) |
| { |
| switch (rpc_type) |
| { |
| |
| case ERPCs.RPC_BS_SKINNED_STATE: |
| { |
| Param1<bool> p_skinned_state= new Param1<bool>(false); |
| if (ctx.Read(p_skinned_state)) |
| { |
| float state = p_skinned_state.param1; |
| if (state && GetCompBS()) |
| GetCompBS().SetAsSkinnedClient(); |
| } |
| break; |
| } |
| |
| case ERPCs.RPC_EXPLODE_EVENT: |
| { |
| OnExplodeClient(); |
| break; |
| } |
| } |
| } |
| } |
|
|
| #ifdef DIAG_DEVELOPER |
| void FixEntity() |
| { |
| if (!(GetGame().IsServer())) |
| return; |
| SetFullHealth(); |
| |
| if (GetInventory()) |
| { |
| int i = 0; |
| int AttachmentsCount = GetInventory().AttachmentCount(); |
| if (AttachmentsCount > 0) |
| { |
| for (i = 0; i < AttachmentsCount; i++) |
| { |
| GetInventory().GetAttachmentFromIndex(i).FixEntity(); |
| } |
| } |
| |
| CargoBase cargo = GetInventory().GetCargo(); |
| if (cargo) |
| { |
| int cargoCount = cargo.GetItemCount(); |
| for (i = 0; i < cargoCount; i++) |
| { |
| cargo.GetItem(i).FixEntity(); |
| } |
| } |
| } |
| } |
| #endif |
|
|
| float GetWetWeightModifier() |
| { |
| return CfgGameplayHandler.GetWetnessWeightModifiers()[GetWetLevel()]; |
| } |
|
|
| float GetConfigWeightModified() |
| { |
| return m_ConfigWeight * GetWetWeightModifier(); |
| } |
|
|
| #ifdef DEVELOPER |
| string GetConfigWeightModifiedDebugText() |
| { |
| if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED) |
| { |
| return "(" + m_ConfigWeight + "(config weight) * " + GetWetWeightModifier() + "(Wetness Modifier))"; |
| } |
| return string.Empty; |
| } |
| #endif |
| |
|
|
| |
| int GetWeight() |
| { |
| return GetWeightEx(); |
| } |
|
|
| void ClearWeightDirty() |
| { |
| |
| m_WeightDirty = 0; |
| } |
|
|
| void SetWeightDirty() |
| { |
| #ifdef DEVELOPER |
| if (WeightDebug.m_VerbosityFlags & WeightDebugType.SET_DIRTY_FLAG) |
| { |
| Print("---------------------------------------"); |
| Print("ent:" + this + " - SetWeightDirty"); |
| if (WeightDebug.m_VerbosityFlags & WeightDebugType.DUMP_STACK) |
| { |
| DumpStack(); |
| } |
| Print("---------------------------------------"); |
| } |
| #endif |
| m_WeightDirty = 1; |
| if (GetHierarchyParent()) |
| { |
| GetHierarchyParent().SetWeightDirty(); |
| } |
| } |
| |
| float GetInventoryAndCargoWeight(bool forceRecalc = false) |
| { |
| float totalWeight; |
| if (GetInventory()) |
| { |
| int i = 0; |
| int AttachmentsCount = GetInventory().AttachmentCount(); |
| if (AttachmentsCount > 0) |
| { |
| for (i = 0; i < AttachmentsCount; i++) |
| { |
| totalWeight += GetInventory().GetAttachmentFromIndex(i).GetWeightEx(forceRecalc); |
| } |
| } |
| |
| CargoBase cargo = GetInventory().GetCargo(); |
| if (cargo) |
| { |
| int cargoCount = cargo.GetItemCount(); |
| for (i = 0; i < cargoCount; i++) |
| { |
| totalWeight += cargo.GetItem(i).GetWeightEx(forceRecalc); |
| } |
| } |
| } |
| return totalWeight; |
| } |
| |
| protected float GetWeightSpecialized(bool forceRecalc = false) |
| { |
| return GetInventoryAndCargoWeight(forceRecalc); |
| } |
|
|
| |
| |
| float GetWeightEx(bool forceRecalc = false) |
| { |
| if (m_WeightDirty || forceRecalc) |
| { |
| m_WeightEx = GetWeightSpecialized(forceRecalc); |
| ClearWeightDirty(); |
| |
| #ifdef DEVELOPER |
| if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED) |
| { |
| WeightDebug.GetWeightDebug(this).SetWeight(m_WeightEx); |
| } |
| if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_DIRTY) |
| { |
| Print("ent:" + this + " - Dirty Recalc"); |
| if (WeightDebug.m_VerbosityFlags & WeightDebugType.DUMP_STACK) |
| { |
| DumpStack(); |
| } |
| } |
| #endif |
| } |
|
|
| return m_WeightEx; |
| } |
| |
| void UpdateWeight(WeightUpdateType updateType = WeightUpdateType.FULL, float weightAdjustment = 0); |
| |
| float GetSingleInventoryItemWeightEx(){} |
|
|
| void GetDebugActions(out TSelectableActionInfoArrayEx outputList) |
| { |
| |
| outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FIX_ENTITY, "Fix Entity", FadeColors.LIGHT_GREY)); |
| |
| |
| outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_TOTAL_WEIGHT, "Print Weight", FadeColors.LIGHT_GREY)); |
| outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_TOTAL_WEIGHT_RECALC, "Print Weight Verbose", FadeColors.LIGHT_GREY)); |
| outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_PLAYER_WEIGHT, "Print Player Weight", FadeColors.LIGHT_GREY)); |
| outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_PLAYER_WEIGHT_RECALC, "Print Player Weight Verbose", FadeColors.LIGHT_GREY)); |
| } |
| bool OnAction(int action_id, Man player, ParamsReadContext ctx) |
| { |
| if (action_id == EActions.FIX_ENTITY) |
| { |
| #ifdef DIAG_DEVELOPER |
| FixEntity(); |
| #endif |
| } |
| else if (action_id == EActions.GET_TOTAL_WEIGHT) |
| { |
| WeightDebug.ClearWeightDebug(); |
| #ifndef SERVER |
| Debug.Log("======================== "+ GetType() +" ================================="); |
| #endif |
| Debug.Log("Weight:" + GetWeightEx().ToString()); |
| Debug.Log("Weight excluding cargo and attachments:" + GetSingleInventoryItemWeightEx()); |
| Debug.Log("----------------------------------------------------------------------------------------------"); |
| } |
| else if (action_id == EActions.GET_TOTAL_WEIGHT_RECALC) |
| { |
| WeightDebug.ClearWeightDebug(); |
| WeightDebug.SetVerbosityFlags(WeightDebugType.RECALC_FORCED); |
| #ifndef SERVER |
| Debug.Log("======================== "+ GetType() +" RECALC ==========================="); |
| #endif |
| Debug.Log("Weight:" + GetWeightEx(true).ToString()); |
| Debug.Log("Weight excluding cargo and attachments:" + GetSingleInventoryItemWeightEx()); |
| WeightDebug.PrintAll(this); |
| Debug.Log("----------------------------------------------------------------------------------------------"); |
| WeightDebug.SetVerbosityFlags(0); |
| } |
| else if (action_id == EActions.GET_PLAYER_WEIGHT) |
| { |
| WeightDebug.ClearWeightDebug(); |
| #ifndef SERVER |
| Debug.Log("======================== PLAYER: "+player+" ==========================="); |
| #endif |
| Debug.Log("New overall weight Player:"+player.GetWeightEx().ToString()); |
|
|
| Debug.Log("----------------------------------------------------------------------------------------------"); |
| } |
| else if (action_id == EActions.GET_PLAYER_WEIGHT_RECALC) |
| { |
| WeightDebug.ClearWeightDebug(); |
| WeightDebug.SetVerbosityFlags(WeightDebugType.RECALC_FORCED); |
| #ifndef SERVER |
| Debug.Log("======================== PLAYER RECALC: "+player+" ==========================="); |
| #endif |
| Debug.Log("New overall weight Player:"+player.GetWeightEx(true).ToString()); |
| WeightDebug.PrintAll(player); |
| Debug.Log("----------------------------------------------------------------------------------------------"); |
| WeightDebug.SetVerbosityFlags(0); |
| } |
| return false; |
| } |
|
|
| |
| |
| |
| int m_ViewIndex = 0; |
| |
| |
| void SetViewIndex( int index ) |
| { |
| m_ViewIndex = index; |
| |
| if( GetGame().IsServer() ) |
| { |
| SetSynchDirty(); |
| } |
| } |
| |
| |
| int GetViewIndex() |
| { |
| if ( MemoryPointExists( "invView2" ) ) |
| { |
| #ifdef PLATFORM_WINDOWS |
| InventoryLocation il = new InventoryLocation(); |
| GetInventory().GetCurrentInventoryLocation( il ); |
| InventoryLocationType type = il.GetType(); |
| switch ( type ) |
| { |
| case InventoryLocationType.CARGO: |
| { |
| return 0; |
| } |
| case InventoryLocationType.ATTACHMENT: |
| { |
| return 1; |
| } |
| case InventoryLocationType.HANDS: |
| { |
| return 0; |
| } |
| case InventoryLocationType.GROUND: |
| { |
| return 1; |
| } |
| case InventoryLocationType.PROXYCARGO: |
| { |
| return 0; |
| } |
| default: |
| { |
| return 0; |
| } |
| } |
| #endif |
| |
| #ifdef PLATFORM_CONSOLE |
| return 1; |
| #endif |
| } |
| return 0; |
| } |
| |
| |
| |
| string GetHitComponentForAI() |
| { |
| Debug.LogError("EntityAI: HitComponentForAI not set properly for that entity (" + GetType() + ")"); |
| |
| return ""; |
| } |
|
|
| |
| string GetDefaultHitComponent() |
| { |
| Debug.LogError("EntityAI: DefaultHitComponent not set properly for that entity (" + GetType() + ")"); |
| |
| return ""; |
| } |
| |
| |
| string GetDefaultHitPositionComponent() |
| { |
| Debug.LogError("EntityAI: DefaultHitPositionComponent not set for that entity (" + GetType() + ")"); |
| return ""; |
| } |
| |
| array<string> GetSuitableFinisherHitComponents() |
| { |
| Debug.LogError("EntityAI: SuitableFinisherHitComponents not set for that entity (" + GetType() + ")"); |
| return null; |
| } |
| |
| vector GetDefaultHitPosition() |
| { |
| Debug.LogError("EntityAI: DefaultHitPosition not set for that entity (" + GetType() + ")"); |
| return vector.Zero; |
| } |
| |
| |
| int GetMeleeTargetType() |
| { |
| return EMeleeTargetType.ALIGNABLE; |
| } |
| |
| |
| string GetAttachmentSoundType() |
| { |
| return "None"; |
| } |
| |
| |
| bool IsHeavyBehaviour() |
| { |
| return false; |
| } |
| |
| |
| bool IsOneHandedBehaviour() |
| { |
| return false; |
| } |
| |
| |
| bool IsTwoHandedBehaviour() |
| { |
| return false; |
| } |
| |
| string ChangeIntoOnAttach(string slot) {} |
| string ChangeIntoOnDetach() {} |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| void OnCEUpdate() |
| { |
| float currentTime = GetGame().GetTickTime(); |
| if (m_LastUpdatedTime == 0) |
| m_LastUpdatedTime = currentTime; |
| |
| m_ElapsedSinceLastUpdate = currentTime - m_LastUpdatedTime; |
| m_LastUpdatedTime = currentTime; |
| } |
|
|
| void OnDebugSpawnEx(DebugSpawnParams params) |
| { |
| OnDebugSpawn(); |
| } |
| |
| void OnDebugSpawn() |
| { |
| array<string> slots = new array<string>; |
| ConfigGetTextArray("Attachments", slots); |
| |
| array<string> mags = new array<string>; |
| ConfigGetTextArray("magazines", mags); |
| |
| |
| |
| TStringArray all_paths = new TStringArray; |
| |
| all_paths.Insert(CFG_VEHICLESPATH); |
| all_paths.Insert(CFG_MAGAZINESPATH); |
| all_paths.Insert(CFG_WEAPONSPATH); |
| |
| string config_path; |
| string child_name; |
| int scope; |
| string path; |
| int consumable_count; |
| |
| for (int i = 0; i < all_paths.Count(); i++) |
| { |
| config_path = all_paths.Get(i); |
| int children_count = GetGame().ConfigGetChildrenCount(config_path); |
| |
| for (int x = 0; x < children_count; x++) |
| { |
| GetGame().ConfigGetChildName(config_path, x, child_name); |
| path = config_path + " " + child_name; |
| scope = GetGame().ConfigGetInt( config_path + " " + child_name + " scope" ); |
| bool should_check = 1; |
| if ( config_path == "CfgVehicles" && scope == 0) |
| { |
| should_check = 0; |
| } |
| |
| if ( should_check ) |
| { |
| string inv_slot; |
| GetGame().ConfigGetText( config_path + " " + child_name + " inventorySlot",inv_slot ); |
| for (int z = 0; z < slots.Count(); z++) |
| { |
| if (slots.Get(z) == inv_slot) |
| { |
| this.GetInventory().CreateInInventory( child_name ); |
| continue; |
| |
| } |
| } |
| } |
| } |
| } |
| }; |
| |
| override EntityAI ProcessMeleeItemDamage(int mode = 0) |
| { |
| if (GetGame().IsServer()) |
| AddHealth("","Health",-MELEE_ITEM_DAMAGE); |
| return this; |
| } |
|
|
| |
| float GetLiquidThroughputCoef() |
| { |
| return LIQUID_THROUGHPUT_DEFAULT; |
| } |
| |
| string GetInvulnerabilityTypeString() |
| { |
| return ""; |
| } |
| |
| void ProcessInvulnerabilityCheck(string servercfg_param) |
| { |
| if ( GetGame() && GetGame().IsMultiplayer() && GetGame().IsServer() ) |
| { |
| int invulnerability; |
| switch (servercfg_param) |
| { |
| case "disableContainerDamage": |
| invulnerability = CfgGameplayHandler.GetDisableContainerDamage(); |
| break; |
| |
| case "disableBaseDamage": |
| invulnerability = CfgGameplayHandler.GetDisableBaseDamage(); |
| break; |
| } |
| |
| if (invulnerability > 0) |
| { |
| SetAllowDamage(false); |
| } |
| } |
| } |
|
|
| void SetBayonetAttached(bool pState, int slot_idx = -1) {}; |
| bool HasBayonetAttached() {}; |
| int GetBayonetAttachmentIdx() {}; |
| |
| void SetButtstockAttached(bool pState, int slot_idx = -1) {}; |
| bool HasButtstockAttached() {}; |
| int GetButtstockAttachmentIdx() {}; |
| |
| void SetInvisibleRecursive(bool invisible, EntityAI parent = null, array<int> attachments = null) |
| { |
| array<int> childrenAtt = new array<int>; |
| array<int> attachmentsArray = new array<int>; |
| if (attachments) |
| attachmentsArray.Copy(attachments); |
| else |
| { |
| for (int i = 0; i < GetInventory().GetAttachmentSlotsCount(); i++) |
| { |
| attachmentsArray.Insert(GetInventory().GetAttachmentSlotId(i)); |
| } |
| } |
| |
| EntityAI item; |
| |
| foreach( int slot : attachmentsArray ) |
| { |
| if( parent ) |
| item = parent.GetInventory().FindAttachment(slot); |
| else |
| item = this; |
| |
| if( item ) |
| { |
| if( item.GetInventory().AttachmentCount() > 0 ) |
| { |
| for(i = 0; i < item.GetInventory().GetAttachmentSlotsCount(); i++) |
| { |
| childrenAtt.Insert(item.GetInventory().GetAttachmentSlotId(i)); |
| } |
| |
| SetInvisibleRecursive(invisible,item,childrenAtt); |
| } |
| |
| item.SetInvisible(invisible); |
| item.OnInvisibleSet(invisible); |
| } |
| } |
| } |
| |
| void SoundHardTreeFallingPlay() |
| { |
| EffectSound sound = SEffectManager.PlaySound( "hardTreeFall_SoundSet", GetPosition() ); |
| sound.SetAutodestroy( true ); |
| } |
| |
| void SoundSoftTreeFallingPlay() |
| { |
| EffectSound sound = SEffectManager.PlaySound( "softTreeFall_SoundSet", GetPosition() ); |
| sound.SetAutodestroy( true ); |
| } |
| |
| void SoundHardBushFallingPlay() |
| { |
| EffectSound sound = SEffectManager.PlaySound( "hardBushFall_SoundSet", GetPosition() ); |
| sound.SetAutodestroy( true ); |
| } |
| |
| void SoundSoftBushFallingPlay() |
| { |
| EffectSound sound = SEffectManager.PlaySound( "softBushFall_SoundSet", GetPosition() ); |
| sound.SetAutodestroy( true ); |
| } |
| |
| void RegisterTransportHit(Transport transport) |
| { |
| if (!m_TransportHitRegistered) |
| { |
| m_TransportHitRegistered = true; |
| m_TransportHitVelocity = GetVelocity(transport); |
| Car car; |
| float damage; |
| vector impulse; |
| |
| |
| if (Car.CastTo(car, transport)) |
| { |
| if (car.GetSpeedometerAbsolute() > 2 ) |
| { |
| damage = m_TransportHitVelocity.Length(); |
| ProcessDirectDamage(DT_CUSTOM, transport, "", "TransportHit", "0 0 0", damage); |
| } |
| else |
| { |
| m_TransportHitRegistered = false; |
| } |
|
|
| |
| if (IsDamageDestroyed() && car.GetSpeedometerAbsolute() > 3) |
| { |
| impulse = 40 * m_TransportHitVelocity; |
| impulse[1] = 40 * 1.5; |
| dBodyApplyImpulse(this, impulse); |
| } |
| } |
| else |
| { |
| |
| if (m_TransportHitVelocity.Length() > 0.1) |
| { |
| damage = m_TransportHitVelocity.Length(); |
| ProcessDirectDamage(DT_CUSTOM, transport, "", "TransportHit", "0 0 0", damage); |
| } |
| else |
| { |
| m_TransportHitRegistered = false; |
| } |
| |
| |
| if (IsDamageDestroyed() && m_TransportHitVelocity.Length() > 0.3) |
| { |
| impulse = 40 * m_TransportHitVelocity; |
| impulse[1] = 40 * 1.5; |
| dBodyApplyImpulse(this, impulse); |
| } |
| } |
| } |
| } |
| |
| bool GetInventoryHandAnimation(notnull InventoryLocation loc, out int value) |
| { |
| value = -1; |
| return false; |
| } |
| |
| bool TranslateSlotFromSelection(string selection_name, out int slot_id) |
| { |
| return false; |
| } |
| |
| |
| bool IsUniversalTemperatureSource() |
| { |
| return GetUniversalTemperatureSource() != null && GetUniversalTemperatureSource().IsActive(); |
| } |
| |
| UTemperatureSource GetUniversalTemperatureSource() |
| { |
| return m_UniversalTemperatureSource; |
| } |
| |
| void SetUniversalTemperatureSource(UTemperatureSource uts) |
| { |
| m_UniversalTemperatureSource = uts; |
| } |
| |
| vector GetUniversalTemperatureSourcePosition() |
| { |
| return GetPosition(); |
| } |
|
|
| |
| RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour(); |
|
|
| void PairRemote(notnull EntityAI trigger); |
|
|
| void UnpairRemote(); |
|
|
| EntityAI GetPairDevice(); |
|
|
| void SetPersistentPairID(int id) |
| { |
| RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour(); |
| if (raib) |
| { |
| raib.SetPersistentPairID(id); |
| } |
| } |
|
|
| |
| bool HasTurnableValveBehavior(); |
| bool IsValveTurnable(int pValveIndex); |
| int GetTurnableValveIndex(int pComponentIndex); |
| void ExecuteActionsConnectedToValve(int pValveIndex); |
|
|
| |
| |
| |
| private void InitAttachmentExclusionValues() |
| { |
| m_AttachmentExclusionSlotMap = new map<int,ref set<int>>(); |
| m_AttachmentExclusionMaskGlobal = new set<int>; |
| m_AttachmentExclusionMaskChildren = new set<int>(); |
| |
| int count = GetInventory().GetSlotIdCount(); |
| |
| if (count == 0) |
| return; |
| |
| InitInherentSlotExclusionMap(); |
| InitGlobalExclusionValues(); |
| InitLegacyConfigExclusionValues(); |
| } |
| |
| |
| private void InitInherentSlotExclusionMap() |
| { |
| int count = GetInventory().GetSlotIdCount(); |
| |
| SetAttachmentExclusionMaskSlot(InventorySlots.INVALID,GetAttachmentExclusionInitSlotValue(InventorySlots.INVALID)); |
| |
| int slotId; |
| for (int i = 0; i < count; i++) |
| { |
| slotId = GetInventory().GetSlotId(i); |
| SetAttachmentExclusionMaskSlot(slotId,GetAttachmentExclusionInitSlotValue(slotId)); |
| } |
| } |
| |
| |
| protected set<int> GetAttachmentExclusionInitSlotValue(int slotId) |
| { |
| set<int> dflt = new set<int>; |
| return dflt; |
| } |
| |
| |
| protected void InitLegacyConfigExclusionValues() |
| { |
| bool performLegacyInit = InitLegacyExclusionCheck(); |
| |
| |
| InitLegacySlotExclusionValuesImplicit(); |
| |
| if (performLegacyInit) |
| InitLegacySlotExclusionValuesDerived(); |
| } |
|
|
| |
| protected bool InitLegacyExclusionCheck() |
| { |
| |
| if (m_AttachmentExclusionMaskGlobal.Count() > 0) |
| return false; |
| |
| |
| int count = m_AttachmentExclusionSlotMap.Count(); |
| if (count > 1) |
| { |
| for (int i = 0; i < count; i++) |
| { |
| int countSet = m_AttachmentExclusionSlotMap.GetElement(i).Count(); |
| if (countSet > 0) |
| { |
| return false; |
| } |
| } |
| } |
| |
| return true; |
| } |
|
|
| |
| |
| |
| |
| |
| protected void InitLegacySlotExclusionValuesImplicit() |
| { |
| int slotId; |
| int slotCount = GetInventory().GetSlotIdCount(); |
| for (int i = 0; i < slotCount; i++) |
| { |
| slotId = GetInventory().GetSlotId(i); |
| set<int> tmp; |
| switch (slotId) |
| { |
| case InventorySlots.HEADGEAR: |
| { |
| tmp = new set<int>; |
| tmp.Copy(GetAttachmentExclusionInitSlotValue(slotId)); |
| tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_MASK); |
| tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_HEADSTRAP); |
| tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_EYEWEWEAR); |
| SetAttachmentExclusionMaskSlot(slotId,tmp); |
| break; |
| } |
| |
| case InventorySlots.MASK: |
| { |
| tmp = new set<int>; |
| tmp.Copy(GetAttachmentExclusionInitSlotValue(slotId)); |
| tmp.Insert(EAttExclusions.LEGACY_MASK_HEADGEAR); |
| tmp.Insert(EAttExclusions.LEGACY_MASK_HEADSTRAP); |
| tmp.Insert(EAttExclusions.LEGACY_MASK_EYEWEWEAR); |
| SetAttachmentExclusionMaskSlot(slotId,tmp); |
| break; |
| } |
| |
| case InventorySlots.EYEWEAR: |
| { |
| tmp = new set<int>; |
| tmp.Copy(GetAttachmentExclusionInitSlotValue(slotId)); |
| if (ConfigGetBool("isStrap")) |
| { |
| tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_HEADGEAR); |
| tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_MASK); |
| } |
| else |
| { |
| tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_HEADGEAR); |
| tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_MASK); |
| } |
| SetAttachmentExclusionMaskSlot(slotId,tmp); |
| break; |
| } |
| } |
| } |
| } |
| |
| protected void InitLegacySlotExclusionValuesDerived() |
| { |
| int slotId; |
| int slotCount = GetInventory().GetSlotIdCount(); |
| for (int i = 0; i < slotCount; i++) |
| { |
| slotId = GetInventory().GetSlotId(i); |
| set<int> tmp; |
| switch (slotId) |
| { |
| case InventorySlots.HEADGEAR: |
| { |
| tmp = new set<int>; |
| tmp.Copy(GetAttachmentExclusionMaskSlot(slotId)); |
| if (ConfigGetBool("noNVStrap")) |
| { |
| tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_HEADGEAR); |
| } |
| if (ConfigGetBool("noMask")) |
| { |
| tmp.Insert(EAttExclusions.LEGACY_MASK_HEADGEAR); |
| } |
| if (ConfigGetBool("noEyewear")) |
| { |
| tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_HEADGEAR); |
| } |
| SetAttachmentExclusionMaskSlot(slotId,tmp); |
| break; |
| } |
| |
| case InventorySlots.MASK: |
| { |
| tmp = new set<int>; |
| tmp.Copy(GetAttachmentExclusionMaskSlot(slotId)); |
| if (ConfigGetBool("noNVStrap")) |
| { |
| tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_MASK); |
| } |
| if (ConfigGetBool("noHelmet")) |
| { |
| tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_MASK); |
| } |
| if (ConfigGetBool("noEyewear")) |
| { |
| tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_MASK); |
| } |
| SetAttachmentExclusionMaskSlot(slotId,tmp); |
| break; |
| } |
| |
| case InventorySlots.EYEWEAR: |
| { |
| tmp = new set<int>; |
| tmp.Copy(GetAttachmentExclusionMaskSlot(slotId)); |
| if (ConfigGetBool("isStrap")) |
| { |
| if (ConfigGetBool("noHelmet")) |
| { |
| tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_HEADSTRAP); |
| } |
| if (ConfigGetBool("noMask")) |
| { |
| tmp.Insert(EAttExclusions.LEGACY_MASK_HEADSTRAP); |
| } |
| } |
| else |
| { |
| if (ConfigGetBool("noHelmet")) |
| { |
| tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_EYEWEWEAR); |
| } |
| if (ConfigGetBool("noMask")) |
| { |
| tmp.Insert(EAttExclusions.LEGACY_MASK_EYEWEWEAR); |
| } |
| } |
| SetAttachmentExclusionMaskSlot(slotId,tmp); |
| break; |
| } |
| } |
| } |
| } |
|
|
| |
| protected void InitGlobalExclusionValues(); |
| |
| |
| protected void AddSingleExclusionValueGlobal(EAttExclusions value) |
| { |
| if (m_AttachmentExclusionMaskGlobal.Find(value) == -1) |
| m_AttachmentExclusionMaskGlobal.Insert(value); |
| } |
| |
| |
| protected void ClearSingleExclusionValueGlobal(EAttExclusions value) |
| { |
| int idx = m_AttachmentExclusionMaskGlobal.Find(value); |
| if (idx != -1) |
| m_AttachmentExclusionMaskGlobal.Remove(idx); |
| } |
| |
| protected void SetAttachmentExclusionMaskGlobal(set<int> values) |
| { |
| m_AttachmentExclusionMaskGlobal.Clear(); |
| m_AttachmentExclusionMaskGlobal.Copy(values); |
| } |
| |
| |
| protected void SetAttachmentExclusionMaskSlot(int slotId, set<int> values) |
| { |
| if (m_AttachmentExclusionSlotMap) |
| { |
| m_AttachmentExclusionSlotMap.Set(slotId,values); |
| } |
| else |
| ErrorEx("m_AttachmentExclusionSlotMap not available! Fill the 'inventorySlot[]' in the " + this + " config file."); |
| } |
| |
| private void PropagateExclusionValueRecursive(set<int> values, int slotId) |
| { |
| if (values && values.Count() != 0) |
| { |
| set<int> passThis; |
| InventoryLocation lcn = new InventoryLocation(); |
| GetInventory().GetCurrentInventoryLocation(lcn); |
| if (CheckExclusionAccessPropagation(lcn.GetSlot(), slotId, values, passThis)) |
| { |
| m_AttachmentExclusionMaskChildren.InsertSet(passThis); |
| EntityAI parent = GetHierarchyParent(); |
| if (parent) |
| parent.PropagateExclusionValueRecursive(passThis,lcn.GetSlot()); |
| } |
| } |
| } |
| |
| private void ClearExclusionValueRecursive(set<int> values, int slotId) |
| { |
| if (values && values.Count() != 0) |
| { |
| set<int> passThis; |
| InventoryLocation lcn = new InventoryLocation(); |
| GetInventory().GetCurrentInventoryLocation(lcn); |
| if (CheckExclusionAccessPropagation(lcn.GetSlot(), slotId, values, passThis)) |
| { |
| int count = passThis.Count(); |
| for (int i = 0; i < count; i++) |
| { |
| m_AttachmentExclusionMaskChildren.RemoveItem(passThis[i]); |
| } |
| EntityAI parent = GetHierarchyParent(); |
| if (parent) |
| parent.ClearExclusionValueRecursive(passThis,lcn.GetSlot()); |
| } |
| } |
| } |
| |
| |
| set<int> GetAttachmentExclusionMaskAll(int slotId) |
| { |
| set<int> values = new set<int>(); |
| set<int> slotValues = GetAttachmentExclusionMaskSlot(slotId); |
| if (slotValues) |
| values.InsertSet(slotValues); |
| values.InsertSet(m_AttachmentExclusionMaskGlobal); |
| values.InsertSet(m_AttachmentExclusionMaskChildren); |
| |
| return values; |
| } |
| |
| |
| set<int> GetAttachmentExclusionMaskSlot(int slotId) |
| { |
| return m_AttachmentExclusionSlotMap.Get(slotId); |
| } |
| |
| |
| set<int> GetAttachmentExclusionMaskGlobal() |
| { |
| return m_AttachmentExclusionMaskGlobal; |
| } |
| |
| |
| set<int> GetAttachmentExclusionMaskChildren() |
| { |
| return m_AttachmentExclusionMaskChildren; |
| } |
| |
| |
| private bool HasInternalExclusionConflicts(int targetSlot) |
| { |
| set<int> targetSlotValues = GetAttachmentExclusionMaskSlot(targetSlot); |
| if (targetSlotValues) |
| { |
| set<int> additionalValues = new set<int>(); |
| additionalValues.InsertSet(GetAttachmentExclusionMaskGlobal()); |
| additionalValues.InsertSet(GetAttachmentExclusionMaskChildren()); |
| |
| int countTarget = targetSlotValues.Count(); |
| for (int i = 0; i < countTarget; i++) |
| { |
| if (additionalValues.Find(targetSlotValues[i]) != -1) |
| { |
| return true; |
| } |
| } |
| } |
| return false; |
| } |
| |
| |
| protected bool IsExclusionFlagPresent(set<int> values) |
| { |
| int slotId; |
| string slotName; |
| GetInventory().GetCurrentAttachmentSlotInfo(slotId,slotName); |
| |
| set<int> currentSlotValuesAll = GetAttachmentExclusionMaskAll(slotId); |
| int count = values.Count(); |
| for (int i = 0; i < count; i++) |
| { |
| if (currentSlotValuesAll.Find(values[i]) != -1) |
| return true; |
| } |
| return false; |
| } |
| |
| |
| protected bool IsExclusionFlagPresentRecursive(set<int> values, int targetSlot) |
| { |
| if (values && values.Count() != 0) |
| { |
| InventoryLocation lcn = new InventoryLocation(); |
| GetInventory().GetCurrentInventoryLocation(lcn); |
| EntityAI parent = GetHierarchyParent(); |
| set<int> passThis; |
| if (CheckExclusionAccessCondition(lcn.GetSlot(),targetSlot, values, passThis)) |
| { |
| if (parent && parent != this) |
| { |
| return parent.IsExclusionFlagPresentRecursive(passThis,lcn.GetSlot()); |
| } |
| } |
| return IsExclusionFlagPresent(passThis); |
| } |
| |
| return false; |
| } |
| |
| |
| protected bool CheckExclusionAccessCondition(int occupiedSlot, int targetSlot, set<int> value, inout set<int> adjustedValue) |
| { |
| bool occupiedException = occupiedSlot == InventorySlots.HANDS || occupiedSlot == InventorySlots.SHOULDER || occupiedSlot == InventorySlots.MELEE || occupiedSlot == InventorySlots.LEFTHAND; |
| bool targetException = targetSlot == InventorySlots.HANDS || targetSlot == InventorySlots.SHOULDER || targetSlot == InventorySlots.MELEE || targetSlot == InventorySlots.LEFTHAND; |
| |
| if (occupiedException) |
| { |
| adjustedValue = value; |
| return false; |
| } |
| |
| if (targetException) |
| { |
| adjustedValue = null; |
| return false; |
| } |
| |
| AdjustExclusionAccessCondition(occupiedSlot,targetSlot,value,adjustedValue); |
| return adjustedValue.Count() != 0; |
| } |
| |
| |
| protected void AdjustExclusionAccessCondition(int occupiedSlot, int testedSlot, set<int> value, inout set<int> adjustedValue) |
| { |
| adjustedValue = value; |
| } |
|
|
| |
| protected bool CheckExclusionAccessPropagation(int occupiedSlot, int targetSlot, set<int> value, inout set<int> adjustedValue) |
| { |
| bool occupiedException = occupiedSlot == InventorySlots.HANDS || occupiedSlot == InventorySlots.SHOULDER || occupiedSlot == InventorySlots.MELEE || occupiedSlot == InventorySlots.LEFTHAND; |
| bool targetException = targetSlot == InventorySlots.HANDS || targetSlot == InventorySlots.SHOULDER || targetSlot == InventorySlots.MELEE || targetSlot == InventorySlots.LEFTHAND || targetSlot == InventorySlots.INVALID; |
| |
| if (targetException) |
| { |
| adjustedValue = null; |
| return false; |
| } |
| |
| AdjustExclusionAccessPropagation(occupiedSlot,targetSlot,value,adjustedValue); |
| return adjustedValue.Count() != 0; |
| } |
| |
| |
| protected void AdjustExclusionAccessPropagation(int occupiedSlot, int testedSlot, set<int> value, inout set<int> adjustedValue) |
| { |
| AdjustExclusionAccessCondition(occupiedSlot,testedSlot,value,adjustedValue); |
| } |
|
|
| bool IsManagingArrows() |
| { |
| return false; |
| } |
|
|
| ArrowManagerBase GetArrowManager() |
| { |
| return null; |
| } |
|
|
| void SetFromProjectile(ProjectileStoppedInfo info) |
| { |
| } |
|
|
| void ClearInventory(); |
| }; |
|
|
| #ifdef DEVELOPER |
| void SetDebugDeveloper_item(Object entity) |
| { |
| if (entity) |
| entity.SetDebugItem(); |
|
|
| } |
| Object _item; |
| #endif |
|
|