3 const float MAX_ACTION_DETECTION_ANGLE_RAD = 1.3;
4 const float MAX_ACTION_DETECTION_DISTANCE = 2.0;
23 if ( MemoryPointExists(
"kit_spawn_position" ) )
26 position = GetMemoryPointPos(
"kit_spawn_position" );
28 return ModelToWorld( position );
36 override void OnPartBuiltServer( notnull Man player,
string part_name,
int action_id )
40 string shelter_type =
"";
44 shelter_type =
"ShelterLeather";
48 shelter_type =
"ShelterFabric";
52 shelter_type =
"ShelterStick";
58 if (shelter_type !=
"")
61 MiscGameplayFunctions.TurnItemIntoItem(
this, shelter_type,
PlayerBase.Cast(player));
63 PluginAdminLog admin_log = PluginAdminLog.Cast(
GetPlugin(PluginAdminLog) );
66 string playerPrefix = admin_log.GetPlayerPrefix(
PlayerBase.Cast(player), player.GetIdentity());
67 admin_log.DirectAdminLogPrint(playerPrefix +
" built " + shelter_type +
" with Hands ");
83 override bool CanUseHandConstruction()
95 vector ref_dir = GetDirection();
105 if ( ref_dir.Length() != 0 )
107 float angle =
Math.Acos( cam_dir * ref_dir );
109 if ( angle >= MAX_ACTION_DETECTION_ANGLE_RAD )
120 vector player_pos = player.GetPosition();
122 vector ref_dir = GetDirection();
127 min = -GetMemoryPointPos(
"BoundingBox_min" );
128 max = -GetMemoryPointPos(
"BoundingBox_max" );
130 vector dir_to_object = object_pos - player_pos;
131 dir_to_object[1] = 0;
132 float len = dir_to_object.Length();
134 dir_to_object.Normalize();
136 vector ref_dir_angle = ref_dir.VectorToAngles();
137 vector dir_to_object_angle = dir_to_object.VectorToAngles();
138 vector test_angles = dir_to_object_angle - ref_dir_angle;
140 vector test_position = test_angles.AnglesToVector() * len;
142 if(test_position[0] > max[0] || test_position[0] < min[0] || test_position[2] > max[2] || test_position[2] < min[2] )
152 if ( MemoryPointExists( selection ) )
154 vector selection_pos = ModelToWorld( GetMemoryPointPos( selection ) );
155 float distance =
vector.Distance( selection_pos, player.GetPosition() );
156 if ( distance >= MAX_ACTION_DETECTION_DISTANCE )
ActionFoldBaseBuildingObjectCB ActionContinuousBaseCB ActionFoldBaseBuildingObject()
ActionPlaceObjectCB ActiondeployObjectCB ActionPlaceObject()
void AddAction(typename actionName)
Construction GetConstruction()
bool MustBeBuiltFromOutside()
Some buildings can only be built from outside.
override bool IsPlayerInside(PlayerBase player, string selection)
override string GetConstructionKitType()
override bool CanPutIntoHands(EntityAI parent)
override void OnPartBuiltServer(notnull Man player, string part_name, int action_id)
override void SetActions()
override bool IsFacingCamera(string selection)
override int GetMeleeTargetType()
override bool HasProperDistance(string selection, PlayerBase player)
override vector GetKitSpawnPosition()
override bool CanBeRepairedToPristine()
proto native CGame GetGame()
class JsonUndergroundAreaTriggerData GetPosition
PluginBase GetPlugin(typename plugin_type)