3 protected float m_TargetUnits;
4 protected float m_SpentQuantity;
5 protected float m_ItemQuantity;
6 protected float m_SourceQuantity;
7 protected float m_QuantityFilledPerSecond;
8 protected float m_TimeToComplete;
9 protected ref Param1<float> m_SpentUnits;
13 m_QuantityFilledPerSecond = quantity_filled_per_second;
21 m_SpentUnits =
new Param1<float>(0);
25 m_SpentUnits.param1 = 0;
27 m_ItemQuantity = action_data.m_MainItem.GetQuantity();
29 if (
Class.CastTo(trg, action_data.m_Target.GetObject()) )
31 m_SourceQuantity = trg.GetQuantity();
33 m_TargetUnits = action_data.m_MainItem.GetQuantityMax();
34 m_TimeToComplete= (
Math.Min((m_TargetUnits-m_ItemQuantity),m_SourceQuantity))/m_QuantityFilledPerSecond;
39 if ( !action_data.m_Player )
44 Class.CastTo(trg, action_data.m_Target.GetObject());
45 if ( action_data.m_MainItem.GetQuantity() >= action_data.m_MainItem.GetQuantityMax() || trg.GetQuantity() == 0 )
51 if ( m_SpentQuantity < m_TargetUnits && m_SpentQuantity < m_SourceQuantity )
53 m_SpentQuantity += m_QuantityFilledPerSecond * action_data.m_Player.GetDeltaT();
54 float val = m_ItemQuantity-m_SpentQuantity;
55 if (
m_Action )
m_Action.SendMessageToClient(action_data.m_Player, val.ToString());
60 CalcAndSetQuantity( action_data );
61 OnCompletePogress(action_data);
67 override override int Cancel(
ActionData action_data )
69 if ( !action_data.m_Player )
74 CalcAndSetQuantity( action_data );
78 override float GetProgress()
80 float progress = (m_SpentQuantity*m_QuantityFilledPerSecond)/m_TimeToComplete;
81 return (m_SpentQuantity*m_QuantityFilledPerSecond)/m_TimeToComplete;
85 void CalcAndSetQuantity(
ActionData action_data )
91 m_SpentUnits.param1 = m_SpentQuantity;
92 SetACData(m_SpentUnits);
94 action_data.m_MainItem.AddQuantity(m_SpentQuantity);
96 if (
Class.CastTo(trg, action_data.m_Target.GetObject()) )
98 trg.AddQuantity(-m_SpentQuantity,
false,
false);