示例#1
0
        // Get pilot of a ship
        // var playerEnt = MyAPIGateway.Session.ControlledObject?.Entity as MyEntity;
        // if (playerEnt?.Parent != null) playerEnt = playerEnt.Parent;

        protected void BlockPlacedHandler(IMySlimBlock block)
        {
            if (block == null)
            {
                return;
            }

            try
            {
                IMyPlayer builder;
                if (!block.IsPlayerBlock(out builder))
                {
                    return;
                }
                IMyFaction faction = builder.GetFaction();
                if (faction != null)
                {
                    DeclareWar(faction);
                }
            }
            catch (Exception scrap)
            {
                Grid.LogError("BlockPlacedHandler", scrap);
            }
        }
示例#2
0
        virtual protected void BlockPlacedHandler(IMySlimBlock Block)
        {
            if (Block == null)
            {
                return;
            }

            try
            {
                IMyPlayer  Builder = null;
                IMyFaction Faction = null;
                if (Block.IsPlayerBlock(out Builder))
                {
                    Faction = Builder.GetFaction();
                    if (Faction != null)
                    {
                        RegisterHostileAction(Faction, CalmdownTime);
                    }
                }
            }
            catch (Exception Scrap)
            {
                Grid.LogError("BlokPlaedHandler", Scrap);
            }
        }