Ejemplo n.º 1
0
 public void GenericDamageHandler(object DamagedObject, MyDamageInformation Damage)
 {
     try
     {
         if (DamagedObject == null)
         {
             return;
         }
         if (!(DamagedObject is IMySlimBlock))
         {
             return;
         }
         IMySlimBlock DamagedBlock = DamagedObject as IMySlimBlock;
         IMyCubeGrid  DamagedGrid  = DamagedBlock.CubeGrid;
         long         GridID       = DamagedGrid.GetTopMostParent().EntityId;
         if (DamageHandlers.ContainsKey(GridID))
         {
             try
             {
                 DamageHandlers[GridID].Invoke(DamagedBlock, Damage);
             }
             catch (Exception Scrap)
             {
                 LogError("DamageHandler.Invoke", Scrap);
             }
         }
     }
     catch (Exception Scrap)
     {
         LogError("GenericDamageHandler", Scrap);
     }
 }
Ejemplo n.º 2
0
        public void GenericDamageHandler(object target, MyDamageInformation info)
        {
            if (target == null || !(target is IMySlimBlock))
            {
                return;
            }
            IMySlimBlock block          = target as IMySlimBlock;
            IMyCubeGrid  grid           = block.CubeGrid;
            long         gridId         = grid.GetTopMostParent().EntityId;
            IMyFaction   damageeFaction = grid.GetOwningFaction();

            IMyPlayer   damagerPlayer;
            IMyFaction  damagerFaction;
            IMyCubeGrid damagerShip;

            if (damageeFaction != null &&
                info.GetSource(out damagerPlayer, out damagerFaction, out damagerShip))
            {
                if (damagerFaction == null)
                {
                    return;
                }
                EmpireData damagerEmpire = damagerFaction.GetEmpire();
                foreach (EmpireManager empire in m_empireManagers)
                {
                    if (empire.GetData().empireTag == damageeFaction.Tag)
                    {
                        empire.TakeStandingsHit(damagerEmpire);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public void GenericDamageHandler(object damagedObject, MyDamageInformation damage)
 {
     try
     {
         if (damage.AttackerId == 0 || !(damagedObject is IMySlimBlock))
         {
             return;
         }
         IMySlimBlock damagedBlock = (IMySlimBlock)damagedObject;
         IMyCubeGrid  damagedGrid  = damagedBlock.CubeGrid;
         long         gridId       = damagedGrid.GetTopMostParent().EntityId;
         if (!DamageHandlers.ContainsKey(gridId))
         {
             return;
         }
         DamageHandlers[gridId].Invoke(damagedBlock, damage);
     }
     catch (Exception scrap)
     {
         LogError("GenericDamageHandler", scrap);
     }
 }
Ejemplo n.º 4
0
 static public bool HasDamageHandler(IMyCubeGrid Grid)
 {
     return(HasDamageHandler(Grid.GetTopMostParent().EntityId));
 }
Ejemplo n.º 5
0
 static public void RemoveDamageHandler(IMyCubeGrid Grid)
 {
     RemoveDamageHandler(Grid.GetTopMostParent().EntityId);
 }
Ejemplo n.º 6
0
 static public void AddDamageHandler(IMyCubeGrid Grid, BotBase.OnDamageTaken Handler)
 {
     AddDamageHandler(Grid.GetTopMostParent().EntityId, Handler);
 }
Ejemplo n.º 7
0
 public void AddDamageHandler(IMyCubeGrid grid, OnDamageTaken handler)
 {
     AddDamageHandler(grid.GetTopMostParent().EntityId, handler);
 }