Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
pileofwoodenplanks.c
Go to the documentation of this file.
1class PileOfWoodenPlanks extends ItemBase
2{
3 void PileOfWoodenPlanks()
4 {
5 if ( GetGame().IsServer() )
6 {
7 SetAllowDamage(false);
8 }
9 }
10
11 // Shows/Hides selections. Call this in init or after every quantity change.
12 void UpdateSelections()
13 {
14 RemoveProxyPhysics( "stage_1" );
15 RemoveProxyPhysics( "stage_2" );
16 RemoveProxyPhysics( "stage_3" );
17
18 // Show/Hide selections according to the current quantity
19 if ( this )
20 {
21 float quantity = GetQuantity();
22 float quantity_max = GetQuantityMax();
23
24 if ( quantity > GetQuantityMax() *0.66 )
25 {
26 // Show 3/3 amount of planks
27 ShowSelection ( "stage_3" );
28 HideSelection ( "stage_2" );
29 HideSelection ( "stage_1" );
30
31 AddProxyPhysics( "stage_3" );
32 }
33
34 if ( quantity > quantity_max *0.33 && quantity <= quantity_max *0.66 )
35 {
36 // Show 2/3 amount of planks
37 HideSelection ( "stage_3" );
38 ShowSelection ( "stage_2" );
39 HideSelection ( "stage_1" );
40
41 AddProxyPhysics( "stage_2" );
42 }
43
44 if ( quantity > 0 && quantity <= quantity_max *0.33 )
45 {
46 // Show 1/3 amount of planks
47 HideSelection ( "stage_3" );
48 HideSelection ( "stage_2" );
49 ShowSelection ( "stage_1" );
50
51 AddProxyPhysics( "stage_1" );
52 }
53
54 if ( quantity == 0 )
55 {
56 // Show 0 planks. Object should be deleted now.
57 HideSelection ( "stage_3" );
58 HideSelection ( "stage_2" );
59 HideSelection ( "stage_1" );
60 }
61 }
62 }
63
64 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
65 {
66 super.EEItemLocationChanged(oldLoc, newLoc);
67 UpdateSelections();
68 }
69
70 // Removes a number of long planks. Note that one (4m) long plank has the length of 3x normal planks!
71 // Returns the number of removed long planks
72 int RemovePlanks( int needed_planks )
73 {
74 // Make sure to not give more long planks than we have available
75 int available_planks = needed_planks;
76 if ( available_planks > GetQuantity() )
77 {
78 available_planks = GetQuantity();
79 }
80
81 // Remove long planks from this object
82 AddQuantity( -available_planks, true ); // Autodelete enabled
83
84 // Return the number of removed long planks
85 return available_planks;
86 }
87
88 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
89 {
90 bool result = super.SetQuantity(value, destroy_config, destroy_forced, allow_client, clamp_to_stack_max);
91 UpdateSelections();
92
93 return result;
94 }
95
96 override bool CanPutIntoHands( EntityAI parent )
97 {
98 return false;
99 }
100
101 override bool CanPutInCargo (EntityAI parent)
102 {
103 return false;
104 }
105}
InventoryLocation.
override bool CanPutInCargo(EntityAI parent)
override bool CanPutIntoHands(EntityAI parent)
proto native CGame GetGame()
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Set item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Definition itembase.c:8148
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Definition itembase.c:8202
override float GetQuantity()
Definition itembase.c:8296
override int GetQuantityMax()
Definition itembase.c:8248
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)