| |
| class BleedingSourcesManagerRemote extends BleedingSourcesManagerBase |
| { |
| int m_BleedingBits; |
| bool m_ShowDiag; |
| bool m_ShowingDiag; |
| bool m_ShowingDiagDraw; |
| Shape m_Point; |
| bool m_EnableHitIndication = false; |
| |
| override protected void Init() |
| { |
| super.Init(); |
| |
| if (GetGame().GetMission().GetEffectWidgets()) |
| { |
| Param3<bool,int,float> par = new Param3<bool,int,float>(true,0,0); |
| GetGame().GetMission().GetEffectWidgets().RegisterGameplayEffectData(EffectWidgetsTypes.BLEEDING_LAYER,par); |
| } |
| } |
| |
| override protected void RegisterBleedingZoneEx(string name, int max_time, string bone = "", vector orientation = "0 0 0", vector offset = "0 0 0", float flow_modifier = 1, string particle_name = "BleedingSourceEffect", int inv_location = 0) |
| { |
| super.RegisterBleedingZoneEx(name,max_time,bone,orientation,offset,flow_modifier,particle_name,inv_location); |
| |
| if (GetGame().GetMission().GetEffectWidgets()) |
| { |
| Param3<bool,int,float> par = new Param3<bool,int,float>(false,m_Bit,flow_modifier); |
| GetGame().GetMission().GetEffectWidgets().RegisterGameplayEffectData(EffectWidgetsTypes.BLEEDING_LAYER,par); |
| } |
| } |
| |
| void OnVariablesSynchronized(int current_bits) |
| { |
| if (current_bits != m_BleedingBits) |
| { |
| if (m_BleedingBits == 0) |
| { |
| m_Player.OnBleedingBegin(); |
| } |
| OnBleedingBitsUpdate(m_BleedingBits, current_bits); |
| m_BleedingBits = current_bits; |
| if (m_BleedingBits == 0) |
| { |
| m_Player.OnBleedingEnd(); |
| } |
| } |
| } |
| |
| void Reload() |
| { |
| m_BleedingSourceZone.Clear(); |
| m_BitOffset = 0; |
| Init(); |
| int bit_offset = 0; |
| |
| for (int i = 0; i < BIT_INT_SIZE; i++) |
| { |
| int bit = 1 << bit_offset; |
| bit_offset++; |
| if ( (bit & m_BleedingBits) != 0 ) |
| { |
| RemoveBleedingSource(bit); |
| AddBleedingSource(bit); |
| } |
| } |
| } |
| |
| |
| override protected void AddBleedingSource(int bit) |
| { |
| super.AddBleedingSource(bit); |
| if (GetGame().IsMultiplayer()) |
| m_Player.OnBleedingSourceAdded(); |
| } |
| |
| override protected bool RemoveBleedingSource(int bit) |
| { |
| if (super.RemoveBleedingSource(bit)) |
| { |
| if (GetGame().IsMultiplayer()) |
| m_Player.OnBleedingSourceRemovedEx(m_Item); |
| return true; |
| } |
| return false; |
| } |
|
|
| void OnBleedingBitsUpdate(int old_mask, int new_mask) |
| { |
| for (int i = 0; i < 32; i++) |
| { |
| int compare_bit = 1 << i; |
| int new_compare_result_bit = compare_bit & new_mask; |
| int old_compare_result_bit = compare_bit & old_mask; |
| |
| if ( new_compare_result_bit ) |
| { |
| if ( !(new_compare_result_bit & old_mask)) |
| { |
| |
| AddBleedingSource(new_compare_result_bit); |
| } |
| } |
| else |
| { |
| if ( new_compare_result_bit != old_compare_result_bit ) |
| { |
| RemoveBleedingSource(old_compare_result_bit); |
| } |
| } |
| } |
| } |
| |
| int GetBleedingSourceCountRemote() |
| { |
| int bleeding_source_count = 0; |
| int pow = 0; |
| |
| for (int i = 0; i < BIT_INT_SIZE ; i++) |
| { |
| int bit = Math.Pow(2, pow); |
| pow++; |
| if ( (m_BleedingBits & bit) != 0) |
| { |
| bleeding_source_count++; |
| } |
| } |
| |
| return bleeding_source_count; |
| } |
| |
| void SetDiag(bool value) |
| { |
| m_ShowDiag = value; |
| return; |
| |
| int boneIdx = m_Player.GetBoneIndexByName("RightArmExtra"); |
|
|
| if ( boneIdx != -1 ) |
| { |
| Object linkedObject = GetGame().CreateObject("Ammo_ArrowBolt", "0 0 0"); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| BleedingSourceEffect eff = new BleedingSourceEffect(); |
| eff.SetAutodestroy(true); |
| SEffectManager.PlayInWorld( eff, "0 0 0" ); |
| Particle p = eff.GetParticle(); |
| |
| m_Player.AddChild(p, boneIdx); |
| |
| m_Player.AddChild(linkedObject, boneIdx); |
| } |
| |
| } |
| |
| void OnUpdate() |
| { |
| #ifndef NO_GUI |
| if (m_ShowDiag) |
| { |
| DisplayDebug(); |
| DisplayVisualDebug(); |
| } |
| else if ( m_ShowingDiag || m_ShowingDiagDraw ) |
| { |
| if (m_ShowingDiag) |
| CleanDebug(); |
| if (m_ShowingDiagDraw) |
| CleanVisualDebug(); |
| } |
| #endif |
| } |
| |
| void DisplayDebug() |
| { |
| m_ShowingDiag = true; |
| |
| DbgUI.BeginCleanupScope(); |
| DbgUI.Begin("Bleeding Sources", 50, 50); |
| |
| int pow = 0; |
| |
| bool anyBleedingSourceActive = false; |
| |
| for (int i = 0; i < BIT_INT_SIZE ; i++) |
| { |
| int bit = Math.Pow(2, pow); |
| pow++; |
| if ( (m_BleedingBits & bit) != 0) |
| { |
| BleedingSourceZone bsz = GetBleedingSourceMeta(bit); |
| |
| string name = GetSelectionNameFromBit(bit); |
| string slot_name = InventorySlots.GetSlotName(bsz.GetInvLocation()); |
| DbgUI.Text(name + "| slot name: "+ slot_name); |
| anyBleedingSourceActive = true; |
| } |
| } |
| |
| if (!anyBleedingSourceActive) |
| { |
| DbgUI.Text("Currently no bleeding sources are active."); |
| } |
| |
| DbgUI.End(); |
| DbgUI.EndCleanupScope(); |
| } |
| |
| void CleanDebug() |
| { |
| m_ShowingDiag = false; |
| |
| DbgUI.BeginCleanupScope(); |
| DbgUI.Begin("Bleeding Sources", 50, 50); |
| DbgUI.End(); |
| DbgUI.EndCleanupScope(); |
| } |
| |
| void DisplayVisualDebug() |
| { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| m_ShowingDiagDraw = true; |
| |
| int bsCount = m_BleedingSources.Count(); |
| for (int i = 0; i < bsCount; ++i) |
| { |
| m_BleedingSources.GetElement(i).DrawDebugShape(); |
| } |
| } |
| |
| void CleanVisualDebug() |
| { |
| m_ShowingDiagDraw = false; |
| |
| int bsCount = m_BleedingSources.Count(); |
| for (int i = 0; i < bsCount; ++i) |
| { |
| m_BleedingSources.GetElement(i).RemoveDebugShape(); |
| } |
| } |
| } |