123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953 |
- class TurnItemIntoItemLambda extends ReplaceItemWithNewLambda
- {
- bool m_TransferAgents;
- bool m_TransferVariables;
- bool m_TransferHealth;
- bool m_ExcludeQuantity;
- float m_quantity_override;
-
- void TurnItemIntoItemLambda (EntityAI old_item, string new_item_type, PlayerBase player)
- {
- SetTransferParams();
- }
-
- void SetTransferParams (bool transfer_agents = true, bool transfer_variables = true, bool transfer_health = true, bool exclude_quantity = false, float quantity_override = -1)
- {
- m_TransferAgents = transfer_agents;
- m_TransferVariables = transfer_variables;
- m_TransferHealth = transfer_health;
- m_ExcludeQuantity = exclude_quantity;
- m_quantity_override = quantity_override;
- }
- override void CopyOldPropertiesToNew (notnull EntityAI old_item, EntityAI new_item)
- {
- super.CopyOldPropertiesToNew(old_item, new_item);
- if (new_item)
- {
- MiscGameplayFunctions.TransferItemProperties(old_item, new_item, m_TransferAgents, m_TransferVariables, m_TransferHealth, m_ExcludeQuantity);
- MiscGameplayFunctions.TransferInventory(old_item, new_item, m_Player);
-
- //quantity override
- if (ItemBase.Cast(new_item) && m_quantity_override != -1)
- {
- m_quantity_override = Math.Max(m_quantity_override,0);
- ItemBase.Cast(new_item).SetQuantity(m_quantity_override);
- }
- }
- else
- {
- Debug.LogError("TurnItemIntoItemLambda: failed to create new item","static");
- }
- }
-
- //! if attaching from att.slot to att.slot, skips the change to "ground" version. Allows for correct property transfers.
- override void VerifyItemTypeBySlotType ()
- {
- if (m_NewLocation.GetType() == InventoryLocationType.ATTACHMENT && m_OldItem.ConfigIsExisting("ChangeIntoOnAttach"))
- {
- string str;
- int idx = -1;
- TStringArray inventory_slots = new TStringArray;
- TIntArray inventory_slots_idx = new TIntArray;
- TStringArray attach_types = new TStringArray;
-
- m_OldItem.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
- if (inventory_slots.Count() < 1) //is string
- {
- inventory_slots_idx.Insert(InventorySlots.GetSlotIdFromString(m_OldItem.ConfigGetString("ChangeInventorySlot")));
- attach_types.Insert(m_OldItem.ConfigGetString("ChangeIntoOnAttach"));
- }
- else //is array
- {
- inventory_slots_idx.Clear();
- for (int i = 0; i < inventory_slots.Count(); ++i)
- {
- inventory_slots_idx.Insert(InventorySlots.GetSlotIdFromString(inventory_slots.Get(i)));
- }
- m_OldItem.ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
- }
-
- idx = m_NewLocation.GetSlot();
- str = attach_types.Get(inventory_slots_idx.Find(idx));
- if (str != "")
- {
- m_NewItemType = str;
- }
- }
- }
-
- override void OnSuccess (EntityAI new_item)
- {
- super.OnSuccess(new_item);
- if( m_Player )
- {
- m_Player.GetItemAccessor().OnItemInHandsChanged();
- }
- }
- };
- class TurnItemIntoItemLambdaAnimSysNotifyLambda extends TurnItemIntoItemLambda
- {
- override void OnSuccess (EntityAI new_item)
- {
- super.OnSuccess(new_item);
- if( m_Player )
- {
- m_Player.GetItemAccessor().OnItemInHandsChanged();
- }
- }
- }
- class TurnItemIntoItemLambdaRestrainLambda extends TurnItemIntoItemLambdaAnimSysNotifyLambda
- {
- override void OnSuccess (EntityAI new_item)
- {
- super.OnSuccess(new_item);
- m_Player.SetRestrained(true);
- }
- }
- /**@class DropEquipAndDestroyRootLambda
- * @brief this one is a bit special: it drops all items and destroys the ex-root of the hierarchy
- **/
- class DropEquipAndDestroyRootLambda : ReplaceItemWithNewLambdaBase
- {
- PlayerBase m_Player;
- void DropEquipAndDestroyRootLambda (EntityAI old_item, string new_item_type, PlayerBase player)
- {
- m_Player = player;
- }
-
- override void CopyOldPropertiesToNew (notnull EntityAI old_item, EntityAI new_item)
- {
- super.CopyOldPropertiesToNew(old_item, new_item);
-
- InventoryLocation understash_src = m_NewLocation; // m_NewLocation is a backup of original old_item's src before the operation started
-
- array<EntityAI> children = new array<EntityAI>;
- old_item.GetInventory().EnumerateInventory(InventoryTraversalType.LEVELORDER, children);
- int count = children.Count();
- for (int i = 0; i < count; ++i)
- {
- EntityAI child = children.Get(i);
- if (child)
- {
- InventoryLocation child_src = new InventoryLocation;
- child.GetInventory().GetCurrentInventoryLocation(child_src);
-
- InventoryLocation child_dst = new InventoryLocation;
- //@TODO: modify _dst with place on gnd?
-
- vector m4[4];
- Math3D.MatrixIdentity4(m4);
-
- //! We don't care if a valid transform couldn't be found, we just want to preferably use it instead of placing on the old item
- GameInventory.PrepareDropEntityPos(old_item, child, m4, false, -1);
-
- child_dst.SetGround(child,m4);
-
- m_Player.LocalTakeToDst(child_src, child_dst);
-
- GetGame().RemoteObjectTreeCreate(child); // this forces server to send CreateVehicle Message to client. This is needed for preserving the appearance of network operations on client (so that DeleteObject(old) arrives before CreateVehicle(new)). @NOTE: this does not delete the object on server, only it's network representation.
- }
- }
- }
- }
- /**@class MoveEquipToExistingItemAndDestroyOldRootLambda
- * @brief this one is a also bit special: it moves all items to already existing item and destroys the ex-root of the hierarchy
- **/
- class MoveEquipToExistingItemAndDestroyOldRootLambda : ReplaceItemWithNewLambdaBase
- {
- PlayerBase m_Player;
- EntityAI m_NewItem;
- void MoveEquipToExistingItemAndDestroyOldRootLambda (EntityAI old_item, string new_item_type, PlayerBase player, EntityAI new_item)
- {
- m_Player = player;
- m_NewItem = new_item;
- if (new_item_type != string.Empty)
- Error("MoveEquipAndDestroyRootLambda expects new_item_type to be empty");
- }
-
- override protected void RemoveNetworkObjectInfo ()
- {
- super.RemoveNetworkObjectInfo();
- GetGame().RemoteObjectTreeDelete(m_NewItem);
- }
- override protected void UndoRemoveNetworkObjectInfo ()
- {
- super.UndoRemoveNetworkObjectInfo();
- GetGame().RemoteObjectTreeCreate(m_NewItem);
- }
-
- override void CopyOldPropertiesToNew (notnull EntityAI old_item, EntityAI new_item)
- {
- // @NOTE: new_item is NULL, this lambda does not create new entity
- super.CopyOldPropertiesToNew(old_item, new_item);
-
- MiscGameplayFunctions.TransferInventory(old_item, m_NewItem, m_Player);
- }
-
- override protected void CreateNetworkObjectInfo (EntityAI new_item)
- {
- super.CreateNetworkObjectInfo(new_item);
- GetGame().RemoteObjectTreeCreate(m_NewItem);
- }
- };
- enum TransferInventoryResult
- {
- Ok, DroppedSome
- };
- enum ThrowEntityFlags
- {
- NONE = 0,
- SPLIT = 1, //< Splits the item when it has quantity, recommended to use when called on an attachment
- }
- class MiscGameplayFunctions
- {
- //! truncate float to specified precision
- static float Truncate(float value, int decimals = 2)
- {
- int multiplier = Math.Pow(10,decimals);
- return Math.Clamp(Math.Floor(value * multiplier),float.LOWEST, float.MAX) / multiplier;
- }
- //! truncate float to specified precision, output as string
- static string TruncateToS(float value, int decimals = 2)
- {
- return Truncate(value, decimals).ToString();
- }
- //! truncate float to specified precision
- static vector TruncateVec(vector value, int decimals = 2)
- {
- int multiplier = Math.Pow(10,decimals);
- float v1 = Math.Clamp(Math.Floor(value[0] * multiplier),float.LOWEST, float.MAX) / multiplier;
- float v2 = Math.Clamp(Math.Floor(value[1] * multiplier),float.LOWEST, float.MAX) / multiplier;
- float v3 = Math.Clamp(Math.Floor(value[2] * multiplier),float.LOWEST, float.MAX) / multiplier;
- return Vector(v1,v2,v3);
- }
-
- static string TruncateVecToS(vector value,int decimals = 2, string delimiter = " ")
- {
- return MiscGameplayFunctions.TruncateToS(value[0],decimals) + delimiter + MiscGameplayFunctions.TruncateToS(value[1],decimals) +delimiter + MiscGameplayFunctions.TruncateToS(value[2],decimals));
- }
-
- static string GetColorString(float r, float g, float b, float a)
- {
- return string.Format("#(argb,8,8,3)color(%1,CO)", string.Format("%1,%2,%3,%4", r, g, b, a));
- }
-
- //! Produces ACII "progress bar" based on an 0..1 'value' input
- static string ValueToBar(float value, string bar = "[----------]", string mark = "x")
- {
- int length = bar.Length() - 2;
- float index = Math.Lerp(0,length, value);
- index = Math.Round(index);
- index = Math.Clamp(index,0,length);
-
- return InsertAtPos(bar,mark,index);
- }
-
- //! Insert 'insert' behind index 'pos' of the 'base' string
- static string InsertAtPos(string base, string insert, int pos)
- {
- int length_first = pos+1;
- int length_base = base.Length();
- int length_second = length_base - length_first;
- string first = base.Substring(0,length_first);
- string second = base.Substring(pos+1,length_second);
- return first + insert + second;
- }
-
- //! will transform variables, agents and other local scripted properties as well as any relevant non-scripted properties like health
- static void TransferItemProperties(EntityAI source, notnull EntityAI target, bool transfer_agents = true, bool transfer_variables = true, bool transfer_health = true, bool exclude_quantity = false)
- {
- ItemBase target_ib = ItemBase.Cast(target);
-
- if (transfer_agents && target_ib)
- target_ib.TransferAgents(source.GetAgents());
-
- if (transfer_variables)
- MiscGameplayFunctions.TransferEntityVariables(source, target, exclude_quantity);
-
- if (GetGame().IsServer() || !GetGame().IsMultiplayer())
- {
- if (transfer_health)
- {
- TransferEntityHealth(source,target,{"Health"});
- }
- }
- }
- static void TransferEntityVariables(EntityAI source, EntityAI target, bool exclude_quantity = false)
- {
- if (exclude_quantity)
- {
- int maskOriginal = source.m_VariablesMask;
- source.RemoveItemVariable(VARIABLE_QUANTITY);
- target.TransferVariablesFloat(source.GetVariablesFloat());
- source.m_VariablesMask = maskOriginal;
- }
- else
- {
- target.TransferVariablesFloat(source.GetVariablesFloat());
- }
-
- if (source.IsMagazine() && target.IsMagazine())
- {
- Magazine source_mag = Magazine.Cast(source);
- Magazine target_mag = Magazine.Cast(target);
-
- target_mag.ServerSetAmmoCount(source_mag.GetAmmoCount());
- }
-
- if (source.IsWeapon() && target.IsWeapon())
- {
- Weapon_Base source_wpn = Weapon_Base.Cast(source);
- Weapon_Base target_wpn = Weapon_Base.Cast(target);
-
- target_wpn.CopyWeaponStateFrom(source_wpn);
- }
-
- if (source.HasEnergyManager() && target.HasEnergyManager())
- {
- ComponentEnergyManager ems = source.GetCompEM();
- ComponentEnergyManager emt = target.GetCompEM();
-
- emt.SetEnergy(ems.GetEnergy());
-
- if (ems.IsSwitchedOn())
- emt.SwitchOn();
- }
-
- Edible_Base source_edb = Edible_Base.Cast(source);
- Edible_Base target_edb = Edible_Base.Cast(target);
- if (Class.CastTo(source_edb,source) && Class.CastTo(target_edb,target))
- {
- if (source_edb.CanDecay() && target_edb.CanDecay())
- target_edb.TransferFoodStage(source_edb);
- }
- }
-
- //! DEPRECATED
- static void TransferItemVariables(ItemBase source, ItemBase target, bool exclude_quantity = false)
- {
- TransferEntityVariables(source,target,exclude_quantity);
- }
- static TransferInventoryResult TransferInventory( EntityAI sourceItem, EntityAI targetItem, PlayerBase player)
- {
- TransferInventoryResult result = TransferInventoryResult.Ok;
- array<EntityAI> children = new array<EntityAI>;
- sourceItem.GetInventory().EnumerateInventory(InventoryTraversalType.LEVELORDER, children);
- int count = children.Count();
- for (int i = 0; i < count; ++i)
- {
- EntityAI child = children.Get(i);
- if (child)
- {
- InventoryLocation child_src = new InventoryLocation;
- child.GetInventory().GetCurrentInventoryLocation( child_src );
-
- InventoryLocation child_dst = new InventoryLocation;
- child_dst.Copy( child_src );
- child_dst.SetParent( targetItem );
- bool drop = false;
- if (GameInventory.LocationCanAddEntity(child_dst))
- {
- // try to move it to the same exact place in dst
- targetItem.GetInventory().TakeToDst(InventoryMode.LOCAL, child_src, child_dst);
- }
- else
- {
- drop = true; // or drop otherwise
- }
- if (drop)
- {
- player.LocalDropEntity(child);
- GetGame().RemoteObjectTreeCreate(child);
- result = TransferInventoryResult.DroppedSome;
- }
- }
- }
- return result;
- }
-
- static void TransferEntityHealth(EntityAI source, EntityAI target, array<string> healthTypes = null, bool transferZoneDamage = true)
- {
- array<string> HPTypes = new array<string>;
- if (!healthTypes || healthTypes.Count() == 0)
- HPTypes.Insert("Health");
- else
- HPTypes.Copy(healthTypes);
-
- if (transferZoneDamage)
- {
- TStringArray zonesSrc = new TStringArray;
- TStringArray zonesTgt = new TStringArray;
- source.GetDamageZones(zonesSrc);
- target.GetDamageZones(zonesTgt);
-
- foreach (string zone : zonesSrc)
- {
- if (zonesTgt.Find(zone) == -1)
- continue;
-
- foreach (string health : HPTypes)
- {
- target.SetHealth01(zone,health,source.GetHealth01(zone,health));
- }
- }
- }
-
- foreach (string gHealth : HPTypes)
- {
- target.SetHealth01("",gHealth,source.GetHealth01("",gHealth)); //global health last
- }
- }
-
- static void UnlimitedAmmoDebugCheck(Weapon_Base weapon)
- {
- if ( ItemBase.GetDebugActionsMask() & DebugActionType.UNLIMITED_AMMO )
- {
- Magazine magazine;
- if ( GetGame().IsServer() )
- {
- magazine = weapon.GetMagazine(weapon.GetCurrentMuzzle());
-
- if (magazine)
- {
- if (magazine.GetAmmoCount() <= 5)
- {
- magazine.ServerSetAmmoMax();
- }
- }
- }
- else
- {
- magazine = weapon.GetMagazine(weapon.GetCurrentMuzzle());
-
- if (magazine)
- {
- if (magazine.GetAmmoCount() <= 5)
- {
- magazine.LocalSetAmmoMax();
- }
- }
-
- }
- }
- }
-
-
- static void TurnItemIntoItem (notnull ItemBase old_item, string new_item_type, notnull PlayerBase player)
- {
- TurnItemIntoItemEx(player, new TurnItemIntoItemLambda(old_item, new_item_type, player));
- }
-
- static void TurnItemIntoItemEx (notnull PlayerBase player, ReplaceItemWithNewLambdaBase lambda)
- {
- player.ServerReplaceItemWithNew(lambda);
- }
- static void TurnItemInHandsIntoItem (notnull ItemBase old_item, string new_item_type, notnull PlayerBase player)
- {
- TurnItemInHandsIntoItemEx(player, new TurnItemIntoItemLambda(old_item, new_item_type, player));
- }
-
- static void TurnItemInHandsIntoItemEx (notnull PlayerBase player, ReplaceItemWithNewLambdaBase lambda)
- {
- player.ServerReplaceItemInHandsWithNew(lambda);
- }
- //!Spawns multiple piles of stackable ItemBase objects on ground (intended for generic use)
- static array<ItemBase> CreateItemBasePiles(string item_name, vector ground_position, float quantity, float health, bool floaty_spawn = false)
- {
- array<ItemBase> item_piles;
- float max_stack_size;
- ItemBase pile;
-
- item_piles = new array<ItemBase>;
- max_stack_size = g_Game.ConfigGetInt("cfgVehicles " + item_name + " varStackMax");
- if( max_stack_size < 1)
- max_stack_size = g_Game.ConfigGetInt("cfgVehicles " + item_name + " varQuantityMax");
- if( max_stack_size < 1)
- max_stack_size = 1;
-
- int full_piles_count = Math.Floor(quantity/max_stack_size);
- int rest = quantity - (full_piles_count*max_stack_size);
-
- for (int i = 0; i < full_piles_count; ++i)
- {
- if (floaty_spawn)
- pile = ItemBase.Cast(GetGame().CreateObjectEx(item_name, ground_position, ECE_CREATEPHYSICS|ECE_UPDATEPATHGRAPH));
- else
- pile = ItemBase.Cast(GetGame().CreateObjectEx(item_name, ground_position, ECE_PLACE_ON_SURFACE));
- pile.SetQuantity(max_stack_size);
- pile.SetHealth(health);
- item_piles.Insert(pile);
- }
-
- if (rest > 0)
- {
- if (floaty_spawn)
- pile = ItemBase.Cast(GetGame().CreateObjectEx(item_name, ground_position, ECE_CREATEPHYSICS|ECE_UPDATEPATHGRAPH));
- else
- pile = ItemBase.Cast(GetGame().CreateObjectEx(item_name, ground_position, ECE_PLACE_ON_SURFACE));
- pile.SetQuantity(rest);
- pile.SetHealth(health);
- item_piles.Insert(pile);
- }
- return item_piles;
- }
-
- //! creation method using raycast-dispersed positioning; ECE_TRACE not used as a result
- static array<ItemBase> CreateItemBasePilesDispersed(string item_name, vector starPos, vector targetPos, float radius, float quantity, float health, Object ignoreObjectCollison)
- {
- array<ItemBase> item_piles;
- float max_stack_size;
- ItemBase pile;
-
- item_piles = new array<ItemBase>;
- max_stack_size = g_Game.ConfigGetInt("cfgVehicles " + item_name + " varStackMax");
- if( max_stack_size < 1)
- max_stack_size = g_Game.ConfigGetInt("cfgVehicles " + item_name + " varQuantityMax");
- if( max_stack_size < 1)
- max_stack_size = 1;
-
- int full_piles_count = Math.Floor(quantity/max_stack_size);
- int rest = quantity - (full_piles_count*max_stack_size);
- vector randomizedPos;
-
- for (int i = 0; i < full_piles_count; ++i)
- {
- randomizedPos = MiscGameplayFunctions.GetRandomizedPositionVerified(starPos,targetPos,radius,ignoreObjectCollison);
- pile = ItemBase.Cast(GetGame().CreateObjectEx(item_name, randomizedPos, ECE_PLACE_ON_SURFACE));
- pile.SetQuantity(max_stack_size);
- pile.SetHealth(health);
- item_piles.Insert(pile);
- }
-
- if (rest > 0)
- {
- randomizedPos = MiscGameplayFunctions.GetRandomizedPositionVerified(starPos,targetPos,radius,ignoreObjectCollison);
- pile = ItemBase.Cast(GetGame().CreateObjectEx(item_name, randomizedPos, ECE_PLACE_ON_SURFACE));
- pile.SetQuantity(rest);
- pile.SetHealth(health);
- item_piles.Insert(pile);
- }
- return item_piles;
- }
-
- static array<Magazine> CreateMagazinePiles(string item_name, vector ground_position, float quantity, float health )
- {
- array<Magazine> items;
- float stack_size;
- Magazine pile;
-
- items = new array<Magazine>;
- stack_size = g_Game.ConfigGetInt("cfgMagazines " + item_name + " count");
-
- int piles_count = Math.Floor(quantity/stack_size);
- int rest = quantity - (piles_count*stack_size);
-
- for (int i = 0; i < piles_count; ++i)
- {
- pile = Magazine.Cast(GetGame().CreateObjectEx(item_name, ground_position, ECE_PLACE_ON_SURFACE));
- pile.ServerSetAmmoCount(stack_size);
- items.Insert(pile);
- }
- if (rest > 0)
- {
- pile = Magazine.Cast(GetGame().CreateObjectEx(item_name, ground_position, ECE_PLACE_ON_SURFACE));
- pile.ServerSetAmmoCount(rest);
- items.Insert(pile);
- }
- return items;
- }
-
- //! creation method using raycast-dispersed positioning; ECE_TRACE not used as a result
- static array<Magazine> CreateMagazinePilesDispersed(string item_name, vector starPos, vector targetPos, float radius, float quantity, float health, Object ignoreObjectCollison)
- {
- array<Magazine> items;
- float stack_size;
- Magazine pile;
-
- items = new array<Magazine>;
- stack_size = g_Game.ConfigGetInt("cfgMagazines " + item_name + " count");
-
- int piles_count = Math.Floor(quantity/stack_size);
- int rest = quantity - (piles_count*stack_size);
- vector randomizedPos;
-
- for (int i = 0; i < piles_count; ++i)
- {
- randomizedPos = MiscGameplayFunctions.GetRandomizedPositionVerified(starPos,targetPos,radius,ignoreObjectCollison);
- pile = Magazine.Cast(GetGame().CreateObjectEx(item_name, randomizedPos, ECE_CREATEPHYSICS|ECE_UPDATEPATHGRAPH));
- pile.ServerSetAmmoCount(stack_size);
- items.Insert(pile);
- }
-
- if (rest > 0)
- {
- randomizedPos = MiscGameplayFunctions.GetRandomizedPositionVerified(starPos,targetPos,radius,ignoreObjectCollison);
- pile = Magazine.Cast(GetGame().CreateObjectEx(item_name, randomizedPos, ECE_CREATEPHYSICS|ECE_UPDATEPATHGRAPH));
- pile.ServerSetAmmoCount(rest);
- items.Insert(pile);
- }
- return items;
- }
-
- static array<Magazine> CreateMagazinePilesFromBullet(string bullet_type, vector ground_position, float quantity, float health )
- {
- array<Magazine> items;
- items = new array<Magazine>;
- float stack_size;
- Magazine pile;
- string item_name;
- if (!g_Game.ConfigGetText("cfgAmmo " + bullet_type + " spawnPileType", item_name))
- return items;
-
- stack_size = g_Game.ConfigGetInt("cfgMagazines " + item_name + " count");
-
- if (stack_size > 0)
- {
- int piles_count = Math.Floor(quantity/stack_size);
- int rest = quantity - (piles_count*stack_size);
-
- for (int i = 0; i < piles_count; ++i)
- {
- pile = Magazine.Cast(GetGame().CreateObjectEx(item_name, ground_position, ECE_PLACE_ON_SURFACE));
- pile.ServerSetAmmoCount(stack_size);
- items.Insert(pile);
- }
-
- if (rest > 0)
- {
- pile = Magazine.Cast(GetGame().CreateObjectEx(item_name, ground_position, ECE_PLACE_ON_SURFACE));
- pile.ServerSetAmmoCount(rest);
- items.Insert(pile);
- }
- }
- return items;
- }
-
- //CreateMagazinePilesDispersed(string item_name, vector starPos, vector targetPos, float radius, float quantity, float health, Object ignoreObjectCollison)
- static array<Magazine> CreateMagazinePilesFromBulletDispersed(string bullet_type, vector starPos, vector targetPos, float radius, float quantity, float health, Object ignoreObjectCollison)
- {
- array<Magazine> items = new array<Magazine>;
- Magazine pile;
- string item_name;
- if (!g_Game.ConfigGetText("cfgAmmo " + bullet_type + " spawnPileType", item_name))
- return items;
-
- items = CreateMagazinePilesDispersed(item_name,starPos,targetPos,radius,quantity,health,ignoreObjectCollison);
- return items;
- }
-
- static int GetHealthLevelForAmmo(string class_name, float health)
- {
- float health_normalized = health / 100;
- string config_path = CFG_WEAPONSPATH + " " + class_name + " DamageSystem" + " GlobalHealth" + " healthLabels";
- CachedObjectsArrays.ARRAY_FLOAT.Clear();
- GetGame().ConfigGetFloatArray(config_path, CachedObjectsArrays.ARRAY_FLOAT);
- for(int i = 0; i < CachedObjectsArrays.ARRAY_FLOAT.Count(); ++i)
- {
- if( health_normalized >= CachedObjectsArrays.ARRAY_FLOAT.Get(i) )
- {
- return i;
- }
- }
- return -1;
- }
-
- static float GetTypeMaxGlobalHealth(string class_name, string health_type = "Health")
- {
- float max_health;
- string cfg_path;
-
- if ( GetGame().ConfigIsExisting(CFG_VEHICLESPATH+" "+class_name) )
- {
- cfg_path = CFG_VEHICLESPATH;
- }
- else if ( GetGame().ConfigIsExisting(CFG_WEAPONSPATH+" "+class_name) )
- {
- cfg_path = CFG_WEAPONSPATH;
- }
- else if ( GetGame().ConfigIsExisting(CFG_MAGAZINESPATH+" "+class_name) )
- {
- cfg_path = CFG_MAGAZINESPATH;
- }
- cfg_path = cfg_path + " "+class_name+" DamageSystem GlobalHealth " + health_type + " hitpoints";
- max_health = GetGame().ConfigGetFloat(cfg_path);
-
- return max_health;
- }
-
- static bool GetProjectedCursorPos3d (out vector position, Weapon_Base weapon)
- {
- vector usti_hlavne_position = weapon.GetSelectionPositionMS( "usti hlavne" );
- vector konec_hlavne_position = weapon.GetSelectionPositionMS( "konec hlavne" );
- vector end_point = weapon.ModelToWorld(usti_hlavne_position);
- vector begin_point = weapon.ModelToWorld(konec_hlavne_position);
- vector contact_dir;
- int contact_component;
-
- vector aim_point = end_point - begin_point;
- aim_point = aim_point.Normalized() * PROJECTED_CURSOR_DISTANCE;
- aim_point = aim_point + end_point;
-
- if (DayZPhysics.RaycastRV(begin_point, aim_point, position, contact_dir, contact_component, null, null, null, false, false, ObjIntersectFire))
- return true;
- return false;
- }
-
- static void GetHeadBonePos(notnull PlayerBase player, out vector pos)
- {
- // Get position of head for starting trace pos, otherwise use sane default
- int headBoneIdx = player.GetBoneIndexByName("Head");
- if ( headBoneIdx == -1 )
- { pos = player.GetPosition()[1] + 1.6; }
- else
- { pos = player.GetBonePositionWS(headBoneIdx); }
- }
- static vector GetHeadingVector(notnull PlayerBase player)
- {
- vector dir = vector.Zero;
- float headingAngle = GetHeadingAngle(player);
- dir[0] = Math.Cos(headingAngle + Math.PI_HALF);
- dir[2] = Math.Sin(headingAngle + Math.PI_HALF);
-
- return dir.Normalized();
- }
- static float GetHeadingAngle(notnull DayZPlayerImplement player)
- {
- HumanInputController hic = player.GetInputController();
- float headingAngle = hic.GetHeadingAngle();
-
- return headingAngle;
- }
-
- static float GetEnergyMetabolicSpeed(int movement_speed)
- {
- float speed;
- switch (movement_speed)
- {
- case DayZPlayerConstants.MOVEMENTIDX_WALK:
- speed = PlayerConstants.METABOLIC_SPEED_ENERGY_WALK;
- break;
- case DayZPlayerConstants.MOVEMENTIDX_RUN:
- speed = PlayerConstants.METABOLIC_SPEED_ENERGY_JOG;
- break;
- case DayZPlayerConstants.MOVEMENTIDX_SPRINT:
- speed = PlayerConstants.METABOLIC_SPEED_ENERGY_SPRINT;
- break;
- default:
- speed = 0;
- break;
- }
- speed += PlayerConstants.METABOLIC_SPEED_ENERGY_BASAL;
- return speed;
- }
-
- static float GetWaterMetabolicSpeed(int movement_speed)
- {
- float speed;
- switch (movement_speed)
- {
- case DayZPlayerConstants.MOVEMENTIDX_WALK:
- speed = PlayerConstants.METABOLIC_SPEED_WATER_WALK;
- break;
- case DayZPlayerConstants.MOVEMENTIDX_RUN:
- speed = PlayerConstants.METABOLIC_SPEED_WATER_JOG;
- break;
- case DayZPlayerConstants.MOVEMENTIDX_SPRINT:
- speed = PlayerConstants.METABOLIC_SPEED_WATER_SPRINT;
- break;
- default:
- speed = 0;
- break;
- }
- speed += PlayerConstants.METABOLIC_SPEED_WATER_BASAL;
- return speed;
- }
-
- static string ObtainRestrainItemTargetClassname(notnull EntityAI entity)
- {
- return entity.ConfigGetString( "OnRestrainChange");
- }
-
- static void TransformRestrainItem(EntityAI current_item, EntityAI tool, PlayerBase player_source, PlayerBase player_target, bool destroy = false)
- {
- bool type;
-
- if ( tool )
- {
- //is unrestrain and not struggle
- type = tool.ConfigGetBool("RestrainUnlockType");
- }
- string new_item_name = current_item.ConfigGetString( "OnRestrainChange");
-
- if ( new_item_name != "" )
- {
- if ( player_target )
- {
- if (player_target.IsAlive())
- MiscGameplayFunctions.TurnItemIntoItemEx(player_target, new ReplaceAndDestroyLambdaEx(current_item, new_item_name, player_target, type));
- else
- MiscGameplayFunctions.TurnItemIntoItemEx(player_source, new DestroyItemInCorpsesHandsAndCreateNewOnGndLambda(current_item, new_item_name, player_target, type));
- }
- else
- {
- MiscGameplayFunctions.TurnItemIntoItemEx(player_target, new ReplaceAndDestroyLambdaEx(current_item, new_item_name, player_target, type));
- }
- }
- else
- {
- Error("current_item:" +current_item+ ", tool:" +tool +". No value for 'OnRestrainChange' config parameter");
- }
- }
-
- static bool IsValueInRange(float value, float from, float to)
- {
- return (value >= from) && (value <= to);
- }
- //! Check if player direction(based on cone of defined angle) is oriented to target position
- static bool IsPlayerOrientedTowardPos(notnull DayZPlayerImplement player, vector target_pos, float cone_angle)
- {
- if (player)
- {
- vector player_dir = player.GetDirection();
- vector to_target_dir = target_pos - player.GetPosition();
-
- player_dir[1] = 0;
- to_target_dir[1] = 0;
-
- player_dir.Normalize();
- to_target_dir.Normalize();
-
- float cos_fi = vector.Dot(player_dir, to_target_dir);
- vector cross = player_dir * to_target_dir;
-
- int dir = Math.Acos(cos_fi) * Math.RAD2DEG;
-
- if( cross[1] < 0 )
- dir = -dir;
- //! dir in cone or in a tip of cone
- if( (dir <= cone_angle && dir >= -cone_angle) || Math.AbsFloat(dir) == 90 )
- {
- return true;
- }
- }
-
- return false;
- }
-
- static string SanitizeString(string input)
- {
- int max_length = 512;
- string output = input;
-
- output = output.Substring(0,Math.Clamp(max_length,0,output.Length()));
- return output;
- }
-
- // deprecated - dont use
- static bool ComplexBuildCollideCheckClient( PlayerBase player, ActionTarget target, ItemBase item, string partName = "" )
- {
- return true;
- }
-
- static bool ComplexBuildCollideCheckClient( PlayerBase player, ActionTarget target, ItemBase item, int constraction_index )
- {
- BaseBuildingBase base_building = BaseBuildingBase.Cast( target.GetObject() );
- if (base_building)
- {
- Construction construction = base_building.GetConstruction();
- if (construction && BuildCondition( player, target, item, false, constraction_index ))
- {
- ConstructionActionData construction_action_data = player.GetConstructionActionData();
- string partName;
- if ( item )
- {
- partName = construction_action_data.GetBuildPartAtIndex(constraction_index).GetPartName();
- }
- else
- {
- partName = construction_action_data.GetBuildPartNoToolAtIndex(constraction_index).GetPartName();
- }
- bool boo;
- if (base_building.PerformRoofCheckForBase(partName,player,boo) && boo)
- return false;
- if ( player.IsPlacingLocal() || player.IsPlacingServer() )
- return false;
-
- /*float distance_root = vector.DistanceSq(target.GetCursorHitPos(), player.GetPosition());
- if (!CfgGameplayHandler.GetDisableDistanceCheck() && distance_root < UAMaxDistances.BASEBUILDING_SHORT)
- {
- return false;
- } */
- return !construction.IsColliding( partName );
- }
- }
- return false;
- }
-
- // deprecated - dont use
- static bool BuildCondition( PlayerBase player, ActionTarget target, ItemBase item, bool camera_check )
- {
- return true;
- }
-
- static bool BuildCondition( PlayerBase player, ActionTarget target, ItemBase item, bool camera_check, int constraction_index )
- {
- Object targetObject = target.GetObject();
- if ( targetObject && targetObject.CanUseConstruction() )
- {
- BaseBuildingBase base_building = BaseBuildingBase.Cast( targetObject );
- ConstructionActionData construction_action_data = player.GetConstructionActionData();
- construction_action_data.SetTarget( targetObject );
-
- ConstructionPart constrution_part;
- if ( item )
- {
- constrution_part = construction_action_data.GetBuildPartAtIndex(constraction_index);
- }
- else
- {
- constrution_part = construction_action_data.GetBuildPartNoToolAtIndex(constraction_index);
- }
- //Debug
- /*
- if ( constrution_part )
- {
- Construction construction = base_building.GetConstruction();
- construction.IsColliding( constrution_part.GetPartName() );
- }
- */
-
- if ( constrution_part )
- {
- //camera and position checks
- bool position_check = ( base_building.MustBeBuiltFromOutside() && !base_building.IsPlayerInside(player, constrution_part.GetMainPartName()) ) || ( !base_building.MustBeBuiltFromOutside() && base_building.IsPlayerInside(player, constrution_part.GetMainPartName()) );
- if ( position_check && !player.GetInputController().CameraIsFreeLook() )
- {
- //Camera check (client-only)
- if ( camera_check )
- {
- if ( GetGame() && ( !GetGame().IsDedicatedServer() ) )
- {
- return !base_building.IsFacingCamera( constrution_part.GetMainPartName() );
- }
- }
-
- return true;
- }
- }
- }
-
- return false;
- }
-
- static void IsUnderRoofFromToCalculation(EntityAI entity, out vector from, out vector to, float height = GameConstants.ROOF_CHECK_RAYCAST_DIST)
- {
- vector minMax[2];
- entity.GetCollisionBox(minMax);
- vector size = Vector(0,0,0);
- //size[1] = minMax[1][1] - minMax[0][1];
- float from_override = entity.HeightStartCheckOverride();
- if (from_override > 0.0)
- {
- size[1] = from_override;
- }
- else
- {
- size[1] = minMax[1][1] - minMax[0][1];
- }
-
- from = entity.GetPosition() + size;
- if ( entity.HeightCheckOverride() > 0 )
- {
- to = entity.GetPosition() + Vector(0, entity.HeightCheckOverride(), 0);
- }
- else
- {
- vector ceiling = "0 0 0";
- ceiling[1] = height;
- to = from + ceiling; //+size ??? offset to cast same distance
- }
- }
-
- static bool IsUnderRoof(EntityAI entity, float height = GameConstants.ROOF_CHECK_RAYCAST_DIST)
- {
- return IsUnderRoofEx(entity, height, ObjIntersectIFire);
- }
-
- static bool IsUnderRoofEx(EntityAI entity, float height = GameConstants.ROOF_CHECK_RAYCAST_DIST, int geometry = ObjIntersectView)
- {
- vector from;
- vector to;
-
- IsUnderRoofFromToCalculation(entity, from, to, height);
- vector contact_pos;
- vector contact_dir;
- int contact_component;
-
- return DayZPhysics.RaycastRV(from, to, contact_pos, contact_dir, contact_component, NULL, NULL, entity, false, false, geometry,0.25);
- }
- // cooking equipment effects (get position for steam particle)
- static vector GetSteamPosition( EntityAI parent )
- {
- vector particle_pos;
- float steam_offset = 0;
-
- if ( parent )
- {
- particle_pos = parent.GetPosition();
-
- if ( parent.IsInherited( PortableGasStove ) )
- {
- steam_offset = 0.2;
- }
- else if ( parent.IsInherited( FireplaceBase ) )
- {
- FireplaceBase fireplace = FireplaceBase.Cast( parent );
-
- if ( fireplace.IsBaseFireplace() )
- {
- steam_offset = 0.8;
- }
- else if ( fireplace.IsBarrelWithHoles() )
- {
- steam_offset = 1.1;
- }
- else if ( fireplace.IsFireplaceIndoor() )
- {
- steam_offset = 0.45;
- }
- else if ( fireplace.IsIndoorOven() )
- {
- steam_offset = 0.9;
- }
- }
- }
-
- particle_pos[1] = particle_pos[1] + steam_offset;
-
- return particle_pos;
- }
-
- static vector GetRandomizedPosition(vector targetPos, float radius)
- {
- int angle = Math.RandomIntInclusive(1,360);
- float usedRadius = Math.RandomFloat01() * radius;
- vector randomPos = Vector(targetPos[0] + (Math.Cos(angle) * usedRadius), targetPos[1], targetPos[2] + (Math.Sin(angle) * usedRadius));
-
- return randomPos;
- }
-
- static vector GetRandomizedPositionVerified(vector startPos, vector targetPos, float radius, Object ignore = null)
- {
- vector ret = GetRandomizedPosition(targetPos,radius);
- RaycastRVParams params = new RaycastRVParams(startPos,ret,ignore);
- params.type = ObjIntersectIFire;
- array<ref RaycastRVResult> results = new array<ref RaycastRVResult>;
- array<Object> excluded = new array<Object>;
- if (DayZPhysics.RaycastRVProxy(params,results,excluded))
- {
- ret = results[0].pos;
- ret[1] = targetPos[1];
- }
- return ret;
- }
-
- static vector GetRandomizedPositionVerifiedPlayer(Man player, float distance, float radius, Object ignore)
- {
- vector startPos;
- MiscGameplayFunctions.GetHeadBonePos(PlayerBase.Cast(player),startPos);
- vector targetPos = player.GetPosition() + (player.GetDirection() * distance);
- return GetRandomizedPositionVerified(startPos,targetPos,radius,ignore);
- }
-
- static void DropAllItemsInInventoryInBounds(ItemBase ib, vector halfExtents)
- {
- if (!GetGame().IsServer())
- return;
- array<EntityAI> items = new array<EntityAI>;
- ib.GetInventory().EnumerateInventory(InventoryTraversalType.LEVELORDER, items);
-
- vector direction = ib.GetDirection();
- float dot = vector.Dot(direction, vector.Forward);
-
- float angle = Math.Acos(dot);
- if (direction[0] < 0)
- angle = -angle;
- float cos = Math.Cos(angle);
- float sin = Math.Sin(angle);
-
- EntityAI item;
- int count = items.Count();
- for ( int i = 0; i < count; ++i )
- {
- item = items.Get(i);
- if ( item )
- ib.GetInventory().DropEntityInBounds(InventoryMode.SERVER, ib, item, halfExtents, angle, cos, sin);
- }
- }
-
- static void ThrowAllItemsInInventory(notnull EntityAI parent, int flags)
- {
- vector position = parent.GetPosition();
- vector orientation = parent.GetOrientation();
- vector rotation_matrix[3];
- float direction[4];
-
- vector minmax[2];
- parent.GetCollisionBox(minmax);
- Math3D.YawPitchRollMatrix( orientation, rotation_matrix );
- Math3D.MatrixToQuat( rotation_matrix, direction );
- vector randomPos;
- for ( int i = 0; i < parent.GetInventory().AttachmentCount(); ++i )
- {
- randomPos = Vector(position[0] + Math.RandomFloat(minmax[0][0], minmax[1][0]),
- position[1] + Math.RandomFloat(minmax[0][1], minmax[1][1]),
- position[2] + Math.RandomFloat(minmax[0][2], minmax[1][2]));
-
- ThrowEntityFromInventory(parent.GetInventory().GetAttachmentFromIndex( i ), randomPos, direction, -GetVelocity(parent), ThrowEntityFlags.NONE);
- }
- for ( int j = 0; j < parent.GetInventory().GetCargo().GetItemCount(); ++j )
- {
- randomPos = Vector(position[0] + Math.RandomFloat(minmax[0][0], minmax[1][0]),
- position[1] + Math.RandomFloat(minmax[0][1], minmax[1][1]),
- position[2] + Math.RandomFloat(minmax[0][2], minmax[1][2]));
-
- ThrowEntityFromInventory(parent.GetInventory().GetCargo().GetItem( j ), randomPos, direction, -GetVelocity(parent), ThrowEntityFlags.NONE);
- }
- }
-
- static void ThrowEntityFromInventory(notnull EntityAI entity, vector position, float direction[4], vector force, int flags)
- {
- InventoryMode invMode = InventoryMode.SERVER;
- if ( !GetGame().IsMultiplayer() )
- invMode = InventoryMode.LOCAL;
-
- ItemBase entityIB;
- if (CastTo(entityIB, entity))
- {
- InventoryLocation dst = new InventoryLocation;
- dst.SetGroundEx(entity, position, direction);
-
- if ( (flags & ThrowEntityFlags.SPLIT) && entityIB.CanBeSplit() )
- {
- for (int l = 0; l < entityIB.GetQuantity(); ++l)
- {
- ItemBase new_item = ItemBase.Cast( GameInventory.LocationCreateEntity( dst, entityIB.GetType(), ECE_NONE, RF_DEFAULT ) );
-
- if ( new_item )
- {
- MiscGameplayFunctions.TransferItemProperties(entityIB, new_item);
- entityIB.AddQuantity( -1 );
- new_item.SetQuantity( 1 );
- new_item.ThrowPhysically(null, force, false);
- }
- }
- }
- else
- {
- float stackable = entityIB.GetTargetQuantityMax();
- if ( !(stackable == 0 || stackable >= entityIB.GetQuantity()) )
- {
- while (entityIB.GetQuantity() > stackable)
- {
- InventoryLocation spltDst = new InventoryLocation;
- position[1] = position[1] + 0.1;
- spltDst.SetGroundEx(entity, position, direction);
-
- ItemBase splitItem = entityIB.SplitIntoStackMaxToInventoryLocationEx( spltDst );
- splitItem.ThrowPhysically(null, force, false);
- }
- }
-
- InventoryLocation src = new InventoryLocation;
- entity.GetInventory().GetCurrentInventoryLocation(src);
-
- entity.GetInventory().TakeToDst(invMode, src, dst);
- entityIB.ThrowPhysically(null, force, false);
- }
- }
- else
- {
- entity.GetInventory().DropEntity(invMode, entity.GetHierarchyRoot(), entity);
- dBodyApplyImpulse(entity, force);
- }
- }
- static float GetCurrentItemHeatIsolation( ItemBase pItem )
- {
- float wetFactor;
- float healthFactor;
- float heatIsolation = pItem.GetHeatIsolation(); //! item heat isolation (from cfg)
- float itemHealthLabel = pItem.GetHealthLevel(); //! item health (state)
- float itemWetness = pItem.GetWet(); //! item wetness
-
- //! wet factor selection
- if ( itemWetness >= GameConstants.STATE_DRY && itemWetness < GameConstants.STATE_DAMP )
- {
- wetFactor = GameConstants.ENVIRO_ISOLATION_WETFACTOR_DRY;
- }
- else if ( itemWetness >= GameConstants.STATE_DAMP && itemWetness < GameConstants.STATE_WET )
- {
- wetFactor = GameConstants.ENVIRO_ISOLATION_WETFACTOR_DAMP;
- }
- else if ( itemWetness >= GameConstants.STATE_WET && itemWetness < GameConstants.STATE_SOAKING_WET )
- {
- wetFactor = GameConstants.ENVIRO_ISOLATION_WETFACTOR_WET;
- }
- else if ( itemWetness >= GameConstants.STATE_SOAKING_WET && itemWetness < GameConstants.STATE_DRENCHED )
- {
- wetFactor = GameConstants.ENVIRO_ISOLATION_WETFACTOR_SOAKED;
- }
- else if ( itemWetness >= GameConstants.STATE_DRENCHED )
- {
- return GameConstants.ENVIRO_ISOLATION_WETFACTOR_DRENCHED;
- }
-
- //! health factor selection
- switch (itemHealthLabel)
- {
- case GameConstants.STATE_PRISTINE:
- healthFactor = GameConstants.ENVIRO_ISOLATION_HEALTHFACTOR_PRISTINE;
- break;
-
- case GameConstants.STATE_WORN:
- healthFactor = GameConstants.ENVIRO_ISOLATION_HEALTHFACTOR_WORN;
- break;
-
- case GameConstants.STATE_DAMAGED:
- healthFactor = GameConstants.ENVIRO_ISOLATION_HEALTHFACTOR_DAMAGED;
- break;
-
- case GameConstants.STATE_BADLY_DAMAGED:
- healthFactor = GameConstants.ENVIRO_ISOLATION_HEALTHFACTOR_B_DAMAGED;
- break;
-
- case GameConstants.STATE_RUINED:
- healthFactor = GameConstants.ENVIRO_ISOLATION_HEALTHFACTOR_RUINED;
- break;
- }
-
- //! apply factors
- heatIsolation *= healthFactor;
- heatIsolation *= wetFactor;
- return heatIsolation;
- }
-
- static void FilterObstructingObjects(array<Object> potentiallyObstructingObjects, out array<Object> obstructingObjects)
- {
- if (!obstructingObjects)
- obstructingObjects = new array<Object>;
-
- for ( int i = 0; i < potentiallyObstructingObjects.Count(); ++i )
- {
- Object obj = potentiallyObstructingObjects[i];
- if ( obj && ( obj.CanObstruct() || obj.CanProxyObstruct() ) )
- obstructingObjects.Insert(obj);
- }
- }
-
- static bool CanIgnoreDistanceCheck(Object obj)
- {
- return obj.IsTransport() || obj.CanUseConstruction();
- }
-
- //! group objects that are close to each other together
- static void FilterObstructedObjectsByGrouping(vector origin, float range, float distanceDelta, array<Object> objects, array<Object> obstructingObjects, out array<Object> filteredObjects, bool doDistanceCheck = false, bool checkIfDistanceCanBeIgnored = false, float maxDist = 0)
- {
- array<Object> vicinityObjects= new array<Object>;
- vicinityObjects.Copy(objects);
-
- int i = 0;
- int j = 0;
- int k = 0;
- int mCount = vicinityObjects.Count();
-
- if (!filteredObjects)
- filteredObjects = new array<Object>;
-
- // Remove objects that are too far from the player anyways
- if ( doDistanceCheck )
- {
- for ( i = vicinityObjects.Count() - 1; i >= 0; --i )
- {
- Object obj = vicinityObjects[i];
- if ( obj && !CanIgnoreDistanceCheck( obj ) && vector.DistanceSq(origin, obj.GetPosition()) > maxDist * maxDist )
- vicinityObjects.Remove(i);
- }
- }
- // Sort obstructingObjects to have the furthest one first
- array<Object> sortedObstructingObjects = new array<Object>;
- array<float> distanceHelper = new array<float>;
- array<float> distanceHelperUnsorted = new array<float>;
- float distance, dist1, dist2;
- for ( i = 0; i < obstructingObjects.Count(); ++i )
- {
- distance = vector.DistanceSq(obstructingObjects[i].GetWorldPosition(), origin);
- distanceHelper.Insert(distance);
- }
- distanceHelperUnsorted.Copy(distanceHelper);
- distanceHelper.Sort();
- for ( i = distanceHelper.Count() - 1; i >= 0; --i )
- sortedObstructingObjects.Insert(obstructingObjects[distanceHelperUnsorted.Find(distanceHelper[i])]);
- array<ref array<Object>> tempGroups = new array<ref array<Object>>;
- array<ref array<Object>> objectGroups = new array<ref array<Object>>;
- array<Object> group;
-
- float cos = Math.Cos(90);
- float sin = Math.Sin(90);
- // Iterate through sorted obstructingObjects
- for ( i = 0; i < sortedObstructingObjects.Count(); ++i )
- {
- Object obstrObj = sortedObstructingObjects[i];
- vector worldPos = obstrObj.GetWorldPosition();
- vector min, max;
- vector minMax[2];
- if ( obstrObj.GetCollisionBox(minMax) )
- {
- min = minMax[0];
- max = minMax[1];
- max = max * (obstrObj.GetOrientation() * range);
- vector center, dx, dy, dz, half;
- center = (min + max) * 0.5;
- dz = obstrObj.GetOrientation();
- dx = vector.RotateAroundZero(dz, vector.Up, cos, sin);
- dy = vector.RotateAroundZero(dz, vector.Aside, cos, sin);
- half = (max - min) * 0.5;
- half = Vector(Math.AbsFloat(half[0]), Math.AbsFloat(half[1]), Math.AbsFloat(half[2]));
- group = new array<Object>;
- // Group objects within the above box
- for ( j = vicinityObjects.Count() - 1; j >= 0; --j )
- {
- Object vicObj = vicinityObjects[j];
- if ( vicObj )
- {
- vector d = vicObj.GetWorldPosition() - worldPos + center;
- if ( Math.AbsFloat(vector.Dot(d, dx)) <= half[0] && Math.AbsFloat(vector.Dot(d, dy)) <= half[1] && Math.AbsFloat(vector.Dot(d, dz)) <= half[2] )
- {
- group.Insert(vicObj);
- vicinityObjects.Remove(j);
- }
- }
- }
- if ( group.Count() > 0 )
- tempGroups.Insert(group);
- }
- }
- // Go through the objects grouped by obstruction to split them by distance too
- for ( i = 0; i < tempGroups.Count(); ++i )
- SplitArrayIntoGroupsByDistance(tempGroups[i], objectGroups, distanceDelta);
- // Split initial groups by distance
- SplitArrayIntoGroupsByDistance(vicinityObjects, objectGroups, distanceDelta);
- // Raycast accordingly to groups
- IsObjectObstructedCache cache = new IsObjectObstructedCache(origin, mCount);
- for ( i = 0; i < objectGroups.Count(); ++i )
- {
- array<Object> objectGroup = objectGroups[i];
- Object sampleObject = objectGroup[0];
- if ( !IsObjectObstructedEx(sampleObject, cache) )
- filteredObjects.InsertAll(objectGroup);
- cache.ClearCache();
- }
- }
- static void SplitArrayIntoGroupsByDistance(array<Object> objects, array<ref array<Object>> objectGroups, float squaredDistanceDelta)
- {
- array<Object> group;
- for ( int i = 0; i < objects.Count(); )
- {
- Object obj1 = objects[i];
- if ( obj1 )
- {
- group = new array<Object>;
- group.Insert(obj1);
- for ( int j = objects.Count() - 1; j > i; --j )
- {
- Object obj2 = objects[j];
- if ( obj1 && obj2 )
- {
- vector start = obj1.GetWorldPosition();
- vector end = obj2.GetWorldPosition();
- float distance = vector.DistanceSq(start, end);
- if ( distance < squaredDistanceDelta )
- {
- group.Insert(obj2);
- objects.Remove(j);
- }
- }
- }
- objectGroups.Insert(group);
- objects.Remove(i);
- continue;
- }
- ++i;
- }
- }
-
- static bool IsObjectObstructed(Object object, bool doDistanceCheck = false, vector distanceCheckPos = "0 0 0", float maxDist = 0)
- {
- vector rayStart;
- MiscGameplayFunctions.GetHeadBonePos(PlayerBase.Cast(GetGame().GetPlayer()), rayStart);
- IsObjectObstructedCache cache = new IsObjectObstructedCache(rayStart, 1);
- return IsObjectObstructedEx(object, cache, doDistanceCheck, distanceCheckPos, maxDist);
- }
- static bool IsObjectObstructedEx(Object object, IsObjectObstructedCache cache, bool doDistanceCheck = false, vector distanceCheckPos = "0 0 0", float maxDist = 0)
- {
- if (!object)
- return true;
-
- PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
- if (doDistanceCheck && vector.DistanceSq(player.GetPosition(), distanceCheckPos) > maxDist * maxDist)
- return true;
- cache.ObjectCenterPos = object.GetCenter();
-
- return IsObjectObstructedFilterEx(object, cache, player);
- }
-
- static bool IsObjectObstructedProxy(Object object, IsObjectObstructedCache cache, PlayerBase player)
- {
- if (object.CanProxyObstruct())
- {
- RaycastRVParams rayInput = new RaycastRVParams(cache.RaycastStart, cache.ObjectCenterPos, player);
- DayZPhysics.RaycastRVProxy(rayInput, cache.HitProxyObjects);
- if (cache.HitProxyObjects)
- {
- if (cache.HitProxyObjects.Count() > 0)
- {
- if (cache.HitProxyObjects[0].hierLevel > 0)
- {
- // ignores attachments on player
- if (!cache.HitProxyObjects[0].parent.IsMan())
- {
- if (cache.HitProxyObjects[0].parent)
- {
- EntityAI proxyParent = EntityAI.Cast(cache.HitProxyObjects[0].parent);
- if (proxyParent.GetInventory() && proxyParent.GetInventory().GetCargo())
- return true;
- }
- }
- }
- }
- }
- }
- return false;
- }
-
- static bool IsObjectObstructedFilter(Object object, IsObjectObstructedCache cache, PlayerBase player)
- {
- for (int m = 0; m < cache.HitObjects.Count(); ++m)
- {
- Object hit_object = cache.HitObjects.Get(m);
-
- if ( hit_object.CanObstruct() )
- return true;
- //4.3. ignore item if items are big and heavy >= OBJECT_OBSTRUCTION_WEIGHT
- //EntityAI eai;
- //if ( Class.CastTo( eai, hit_object ) )
- //{
- // if ( eai.GetWeight() >= OBJECT_OBSTRUCTION_WEIGHT )
- // {
- // if ( eai != filtered_object && eai.GetHierarchyRoot() != filtered_object )
- // {
- // //Print("!!!!!obstacle vaha: " + hit_object);
- // is_obstructed = true;
- // }
- // }
- //}
- }
-
- return false;
- }
-
- //! groups 'RaycastRVProxy' and 'RaycastRV' approaches into one method, allowes for comprehensive geometry override, if desired
- static bool IsObjectObstructedFilterEx(Object object, IsObjectObstructedCache cache, PlayerBase player, int geometryTypeOverride = -1)
- {
- //first proxy geometries
- RaycastRVParams rayInput = new RaycastRVParams(cache.RaycastStart, cache.ObjectCenterPos, player);
- rayInput.flags = CollisionFlags.ALLOBJECTS;
- if (geometryTypeOverride != -1)
- rayInput.type = geometryTypeOverride; //default 'ObjIntersectView'
- DayZPhysics.RaycastRVProxy(rayInput, cache.HitProxyObjects);
- int count;
- int i;
-
- if (cache.HitProxyObjects)
- {
- count = cache.HitProxyObjects.Count();
- Object parent;
- for (i = 0; i < count; ++i)
- {
- if (cache.HitProxyObjects[i].hierLevel > 0) //parent has to exist, skipping nullcheck
- {
- parent = cache.HitProxyObjects[i].parent;
- if (parent && !parent.IsMan() && parent.CanProxyObstruct())
- {
- if (parent != object || (parent == object && object.CanProxyObstructSelf()))
- return true;
- }
- }
- }
- }
-
- //second, regular raycast
- int geometry = ObjIntersectFire; //default for the RV raycast
- if (geometryTypeOverride != -1)
- geometry = geometryTypeOverride;
- DayZPhysics.RaycastRV(cache.RaycastStart, cache.ObjectCenterPos, cache.ObjectContactPos, cache.ObjectContactDir, cache.ContactComponent, cache.HitObjects, object, GetGame().GetPlayer(), false, false, geometry, 0.0, CollisionFlags.ALLOBJECTS);
- count = cache.HitObjects.Count();
- for (i = 0; i < count; ++i)
- {
- if (cache.HitObjects[i].CanObstruct())
- return true;
- }
-
- return false;
- }
- //Inflict damage to item based on environmental temperature and surface type
- static void DealEvinronmentAdjustedDmg(ItemBase item, PlayerBase player, float baseDamage)
- {
- string surfaceType;
- int liquidType;
- float adjustedDamage;
-
- GetGame().SurfaceUnderObject(player, surfaceType, liquidType);
- float modifierSurface = Surface.GetParamFloat(surfaceType, "toolDamage"); // toolDamage
- if (modifierSurface == 0)
- modifierSurface = 1;
-
- if (player.GetInColdArea())
- adjustedDamage = baseDamage * (modifierSurface + GetGame().GetMission().GetWorldData().GetColdAreaToolDamageModifier();
- else
- adjustedDamage = baseDamage * modifierSurface;
-
- DealAbsoluteDmg(item, adjustedDamage);
- }
-
- //Inflict absolute damage to item (used on tools when completing actions)
- static void DealAbsoluteDmg(ItemBase item, float dmg)
- {
- item.DecreaseHealth(dmg, false);
- }
-
- //Function used to normailze values, enter the used value and the max value (max will become 1)
- static float Normalize(int val, int maxVal)
- {
- if (maxVal == 0)
- {
- Debug.LogError("Division by 0 is not allowed");
- return 0;
- }
-
- return val / maxVal;
- }
-
- static float Bobbing(float period, float amplitude, float elapsedTime)
- {
- //Prevent division by 0
- if ( period == 0 )
- period = 1;
-
- elapsedTime /= period;
-
- float cycle;
- cycle += elapsedTime;
- cycle = FModulus(cycle, 360);
- cycle = Math.Sin(cycle) * amplitude;
-
- return cycle;
- }
-
- // DEPRECATED, use Math.ModFloat directly instead
- static float FModulus(float x, float y)
- {
- return Math.ModFloat(x, y);
- }
-
- static void RemoveSplint( PlayerBase player )
- {
- EntityAI entity = player.GetInventory().CreateInInventory("Splint");
- if (!entity)
- entity = player.SpawnEntityOnGroundOnCursorDir("Splint", 0.5);
-
- EntityAI attachment;
- ItemBase new_item = ItemBase.Cast(entity);
- Class.CastTo(attachment, player.GetItemOnSlot("Splint_Right"));
- if ( attachment && attachment.GetType() == "Splint_Applied" )
- {
- if (new_item)
- {
- MiscGameplayFunctions.TransferItemProperties(attachment,new_item);
-
- if (GetGame().IsServer())
- {
- //Lower health level of splint after use
- if (new_item.GetHealthLevel() < 4)
- {
- int newDmgLevel = new_item.GetHealthLevel() + 1;
-
- float max = new_item.GetMaxHealth("","");
-
- switch ( newDmgLevel )
- {
- case GameConstants.STATE_BADLY_DAMAGED:
- new_item.SetHealth( "", "", max * GameConstants.DAMAGE_BADLY_DAMAGED_VALUE );
- break;
-
- case GameConstants.STATE_DAMAGED:
- new_item.SetHealth( "", "", max * GameConstants.DAMAGE_DAMAGED_VALUE );
- break;
-
- case GameConstants.STATE_WORN:
- new_item.SetHealth( "", "", max * GameConstants.DAMAGE_WORN_VALUE );
- break;
-
- case GameConstants.STATE_RUINED:
- new_item.SetHealth( "", "", max * GameConstants.DAMAGE_RUINED_VALUE );
- break;
-
- default:
- break;
- }
- }
- }
- }
-
- attachment.Delete();
- }
- }
-
- //! checks if we should teleport the player to a safe location and if so, performs the teleportation
- static void TeleportCheck(notnull PlayerBase player, notnull array<ref array<float>> safe_positions)
- {
- if( player.GetSimulationTimeStamp() < 20 && !player.IsPersistentFlag(PersistentFlag.AREA_PRESENCE) )
- {
- //simulation time is bellow a threshold, which means the player has recently connected,
- //the player does not have the AREA_PRESENCE flag set, which means they were not inside the area when they disconnected,
- //that means they just spawned into a contaminated area, lets move them somewhere safe
- vector player_pos = player.GetPosition();
- vector closest_safe_pos = MiscGameplayFunctions.GetClosestSafePos(player_pos, safe_positions);
-
- if (player_pos!=closest_safe_pos)
- {
- closest_safe_pos[1] = GetGame().SurfaceY(closest_safe_pos[0], closest_safe_pos[2]);
-
- player.SetPosition( closest_safe_pos );//...so lets teleport them somewhere safe
- //DeveloperTeleport.SetPlayerPosition(player, closest_safe_pos);
- GetGame().RPCSingleParam(player, ERPCs.RPC_WARNING_TELEPORT, null, true, player.GetIdentity());
-
- PluginAdminLog adminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
- if (adminLog)
- adminLog.PlayerTeleportedLog(player,player_pos,closest_safe_pos,"Unwillingly spawning in contaminated area.");
- }
-
- player.SetPersistentFlag(PersistentFlag.AREA_PRESENCE, false);
- }
- }
-
- static vector GetClosestSafePos(vector to_pos, notnull array<ref array<float>> positions)
- {
- vector closest_pos = to_pos;
- float smallest_dist = float.MAX;
- foreach( array<float> pos:positions)
- {
- vector vpos = "0 0 0";
- vpos[0] = pos[0];
- vpos[2] = pos[1];
- to_pos[1] = 0;
- float dist = vector.DistanceSq(to_pos, vpos);//2d dist sq
- if ( dist < smallest_dist)
- {
- smallest_dist = dist;
- closest_pos = vpos;
- }
- }
- return closest_pos;
- }
-
- //! 'stupider' teleport method, does not touch flag management. Applies Y from the position as well!
- static bool TeleportPlayerToSafeLocation3D(notnull PlayerBase player, vector safePos)
- {
- vector playerPos = player.GetPosition();
- if (playerPos != safePos)
- {
- player.SetPosition(safePos);
- GetGame().RPCSingleParam(player, ERPCs.RPC_WARNING_TELEPORT, null, true, player.GetIdentity());
-
- return true;
- }
-
- return false;
- }
-
- static void GenerateAINoiseAtPosition(vector position, float lifeTime, NoiseParams noiseParams)
- {
- if (GetGame().IsServer())
- {
- NoiseSystem noise = GetGame().GetNoiseSystem();
- if (noise)
- {
- noise.AddNoiseTarget(position, lifeTime, noiseParams, NoiseAIEvaluate.GetNoiseReduction(GetGame().GetWeather()));
- }
- }
- }
- static float GetMinValue(array<float> pArray)
- {
- float minValue = 0.0;
- for (int i = 0; i < pArray.Count(); ++i)
- {
- if (minValue == 0 || pArray.Get(i) < minValue)
- {
- minValue = pArray.Get(i);
- }
- }
-
- return minValue;
- }
-
- static float GetMaxValue(array<float> pArray)
- {
- float maxValue = 0.0;
- for (int i = 0; i < pArray.Count(); ++i)
- {
- if (maxValue == 0 || pArray.Get(i) > maxValue)
- {
- maxValue = pArray.Get(i);
- }
- }
-
- return maxValue;
- }
-
- static string GetItemDisplayName(string type)
- {
- return GetGame().ConfigGetTextOut("CfgVehicles " + type + " displayName");
- }
- static bool IsComponentInSelection(array<Selection> pSelection, string pCompName)
- {
- if (pSelection.Count() == 0 || pCompName.Length() == 0)
- {
- return false;
- }
- for (int i = 0; i < pSelection.Count(); ++i)
- {
- pCompName.ToLower();
- if (pSelection[i] && pSelection[i].GetName() == pCompName)
- {
- return true;
- }
- }
- return false;
- }
-
- static int GetComponentIndex(array<Selection> pSelection, string pCompName)
- {
- if (!MiscGameplayFunctions.IsComponentInSelection(pSelection, pCompName))
- {
- return INDEX_NOT_FOUND;
- }
- for (int i = 0; i < pSelection.Count(); ++i)
- {
- pCompName.ToLower();
- if (pSelection[i] && pSelection[i].GetName() == pCompName)
- {
- return i;
- }
- }
- return INDEX_NOT_FOUND;
- }
-
- static void RemoveAllAttachedChildrenByTypename(notnull EntityAI parent, array<typename> listOfTypenames)
- {
- if (listOfTypenames.Count() > 0)
- {
- Object child = Object.Cast(parent.GetChildren());
- while (child)
- {
- Object childToRemove = child;
- child = Object.Cast(child.GetSibling());
-
- if (childToRemove.IsAnyInherited(listOfTypenames))
- {
- vector pos = parent.GetPosition();
- parent.RemoveChild(childToRemove, false);
-
- vector m4[4];
- Math3D.MatrixIdentity4(m4);
- m4[3] = pos;
- childToRemove.SetTransform(m4);
- childToRemove.PlaceOnSurface();
- }
- }
- }
- }
-
- static void DeleteAttachedChildrenByTypename(notnull EntityAI parent, array<typename> listOfTypenames)
- {
- if (listOfTypenames.Count() > 0)
- {
- Object child = Object.Cast(parent.GetChildren());
- while (child)
- {
- Object childToRemove = child;
- child = Object.Cast(child.GetSibling());
-
- if (childToRemove.IsAnyInherited(listOfTypenames))
- {
- parent.RemoveChild(childToRemove, false);
- childToRemove.Delete();
- }
- }
- }
- }
-
- //! Fills the provided array with all children entities in hierarchy of this entity
- static void GetAttachedChildren(IEntity parent, array<IEntity> outputObjects)
- {
- IEntity child = parent.GetChildren();
- while (child)
- {
- outputObjects.Insert(child);
- child = child.GetSibling();
- }
- }
-
- static void SoakItemInsideParentContainingLiquidAboveThreshold(notnull ItemBase item, notnull ItemBase parent, float liquidQuantityThresholdPercentage = 0.05)
- {
- if (g_Game.IsServer())
- {
- if (parent.GetLiquidType() != 0 && parent.GetQuantityNormalized() > liquidQuantityThresholdPercentage && !parent.GetIsFrozen())
- item.SetWetMax();
- }
- }
- static float GetCombinedSnowfallWindValue()
- {
- float windMin;
- float windMax;
- g_Game.GetWeather().GetWindMagnitude().GetLimits(windMin, windMax);
- float snowfall = g_Game.GetWeather().GetSnowfall().GetActual();
- float value = snowfall + g_Game.GetWeather().GetWindMagnitude().GetActual() / windMax;
-
- return value;
- }
- }
- class DestroyItemInCorpsesHandsAndCreateNewOnGndLambda : ReplaceAndDestroyLambda
- {
- // @NOTE m_Player == target player - i.e. restrained one
- void DestroyItemInCorpsesHandsAndCreateNewOnGndLambda(EntityAI old_item, string new_item_type, PlayerBase player, bool destroy = false)
- {
- InventoryLocation gnd = new InventoryLocation;
- vector mtx[4];
- if (old_item)
- old_item.GetTransform(mtx);
- else
- player.GetTransform(mtx);
- gnd.SetGround(NULL, mtx);
- OverrideNewLocation(gnd);
- }
-
- protected override void RemoveOldItemFromLocation()
- {
- super.RemoveOldItemFromLocation();
- m_Player.GetHumanInventory().OnEntityInHandsDestroyed(m_OldLocation);
- }
- }
- // This was created since IsObjectObstructed is often called multiple times in one frame
- // And apparently it seems that keeping this data in one struct seems to be more efficient than creating the variables dozens of times per frame
- class IsObjectObstructedCache // Pretending this is a struct
- {
- // Outside data
- vector RaycastStart = "0 0 0";
- int TotalObjects = 0;
-
- // Inside data
- vector ObjectCenterPos = "0 0 0";
- vector ObjectContactPos = "0 0 0";
- vector ObjectContactDir = "0 0 0";
- int ContactComponent = -1;
- ref array<ref RaycastRVResult> HitProxyObjects = new array<ref RaycastRVResult>;
- ref set<Object> HitObjects = new set<Object>;
-
- void IsObjectObstructedCache(vector rayCastStart, int totalObjects)
- {
- RaycastStart = rayCastStart;
- TotalObjects = totalObjects;
- }
-
- // Only inside data
- void ClearCache()
- {
- ObjectCenterPos = "0 0 0";
- ObjectContactPos = "0 0 0";
- ObjectContactDir = "0 0 0";
- ContactComponent = -1;
- HitProxyObjects.Clear();
- HitObjects.Clear();
- }
- }
|