Example #1
0
        public void ProcessRemoteHealthChange(NitroxId id, float LifeChanged, Optional <DamageTakenData> opDamageTakenData, float totalHealth)
        {
            if (simulationOwnership.HasAnyLockType(id))
            {
                Log.Error($"Got LiveMixin change health for {id} but we have the simulation already. This should not happen!");
                return;
            }
            LiveMixin liveMixin = NitroxEntity.RequireObjectFrom(id).GetComponent <LiveMixin>();

            // For remote processing, we add an outstanding health change that makes it possible to pass execution
            outstandingChangeHealth.Add(id, new Tuple <float, float>(LifeChanged, liveMixin.health));
            if (LifeChanged < 0)
            {
                DamageTakenData       damageTakenData = opDamageTakenData.OrElse(null);
                Optional <GameObject> opDealer        = damageTakenData.DealerId.HasValue ? NitroxEntity.GetObjectFrom(damageTakenData.DealerId.Value) : Optional.Empty;
                GameObject            dealer          = opDealer.HasValue ? opDealer.Value : null;
                if (!dealer && damageTakenData.DealerId.HasValue)
                {
                    Log.Warn($"Could not find entity {damageTakenData.DealerId.Value} for damage calculation. This could lead to problems.");
                }
                liveMixin.TakeDamage(-LifeChanged, damageTakenData.Position.ToUnity(), (DamageType)damageTakenData.DamageType, dealer);
            }
            else
            {
                liveMixin.AddHealth(LifeChanged);
            }

            // Check if the health calculated by the game is the same as the calculated damage from the simulator
            if (liveMixin.health != totalHealth)
            {
                Log.Warn($"Calculated health and send health for {id} do not align (Calculated: {liveMixin.health}, send:{totalHealth}). This will be correted but should be investigated");
                liveMixin.health = totalHealth;
            }
        }
Example #2
0
 public List <CombatItem> GetDamageTakenData(ushort key, long start, long end)
 {
     if (DamageTakenData.TryGetValue(key, out List <CombatItem> res))
     {
         return(res.Where(x => x.Time >= start && x.Time <= end).ToList());
     }
     return(new List <CombatItem>());
 }
Example #3
0
 public List <CombatItem> GetDamageTakenData(ushort key)
 {
     if (DamageTakenData.TryGetValue(key, out List <CombatItem> res))
     {
         return(res);
     }
     return(new List <CombatItem>());
 }