9class ActionDigInStash: ActionContinuousBase
11 static float m_DigStashSlopeTolerance = 0.6;
13 void ActionDigInStash()
29 override bool Can(
PlayerBase player, ActionTarget target,
ItemBase item,
int condition_mask)
31 if (!super.Can(player, target, item, condition_mask))
34 return player.CheckFreeSpace(
vector.Forward, 1.0,
false);
40 if (
Class.CastTo(targetIB, target.GetObject()) && targetIB.CanBeDigged())
42 if (player.IsPlacingLocal())
47 if (targetIB.IsRuined() || targetIB.GetInventory().IsAttachment())
52 if (targetIB.GetInventory().IsAttachment())
57 if (targetIB.IsInherited(UndergroundStash))
64 if (targetIB.GetInventory().IsInCargo())
65 entityToCheck = player;
69 excludedObjects.Insert(targetIB);
72 if (
g_Game.IsBoxColliding(entityToCheck.GetPosition(), entityToCheck.GetOrientation(),
"2 2 2", excludedObjects, nearbyObjects))
74 foreach (
Object nearbyObject : nearbyObjects)
76 if (nearbyObject.IsInherited(UndergroundStash))
84 g_Game.SurfaceUnderObject(entityToCheck, surfaceType, liquidType);
85 if (!
g_Game.IsSurfaceDigable(surfaceType))
92 vector position = entityToCheck.GetPosition();
95 positions.Insert(position +
"0.5 0 0.5");
96 positions.Insert(position +
"-0.5 0 0.5");
97 positions.Insert(position +
"0.5 0 -0.5");
98 positions.Insert(position +
"-0.5 0 -0.5");
100 float difference =
g_Game.GetHighestSurfaceYDifference(positions);
102 return difference < m_DigStashSlopeTolerance;
109 override void OnExecuteClient(
ActionData action_data)
111 super.OnExecuteClient(action_data);
113 SpawnParticleShovelRaise(action_data);
116 override void OnExecuteServer(
ActionData action_data)
118 super.OnExecuteServer(action_data);
120 if (!
g_Game.IsMultiplayer())
122 SpawnParticleShovelRaise(action_data);
126 void SpawnParticleShovelRaise(
ActionData action_data)
131 override void OnFinishProgressServer(
ActionData action_data)
136 ErrorEx(
"Cannot get entity=" + targetEntity);
141 if (!targetEntity.GetInventory().GetCurrentInventoryLocation(targetIL))
143 ErrorEx(
"Cannot get inventory location of entity=" + targetEntity);
147 EntityAI entityToCheck = targetEntity;
148 if (targetEntity.GetInventory().IsInCargo())
149 entityToCheck = action_data.m_Player;
153 g_Game.SurfaceUnderObject(entityToCheck, surfaceType, liquidType);
154 string undergroundStashType;
156 g_Game.GetSurfaceDigPile(surfaceType, undergroundStashType);
158 if (undergroundStashType ==
"")
159 undergroundStashType =
"UndergroundStash";
161 UndergroundStash stash = UndergroundStash.Cast(
g_Game.CreateObjectEx(undergroundStashType, targetEntity.GetPosition(),
ECE_PLACE_ON_SURFACE));
165 stash.PlaceOnGround();
167 stash.GetInventory().GetCurrentInventoryLocation(ilj);
171 if (!
g_Game.IsMultiplayer())
174 action_data.m_Player.LocalTakeEntityToTargetCargo(stash, targetEntity);
177 action_data.m_Player.ServerTakeEntityToTargetCargo(stash, targetEntity);
181 Debug.Log(
string.Format(
"Cannot remove entity=%1 obj from current location=%2", targetEntity,
InventoryLocation.DumpToStringNullSafe(targetIL)));
190 MiscGameplayFunctions.DealEvinronmentAdjustedDmg(action_data.m_MainItem, action_data.m_Player, 10);
193 override string GetAdminLogMessage(
ActionData action_data)
195 return string.Format(
"Player %1 Dug in %2 at position %3", action_data.m_Player, action_data.m_Target.GetObject(), action_data.m_Target.GetObject().GetPosition());
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor).