Ejemplo n.º 1
0
 public MyDebugRenderComponentLandingGear(MyLandingGear landingGear)
     : base(landingGear)
 {
     m_langingGear = landingGear;
 }
Ejemplo n.º 2
0
        private static bool AttachCheck(ref bool __result, MyLandingGear __instance, MyEntity entity, Vector3D worldPos)
        {
            if (!Config.Instance.EnablePlugin || Config.Instance.AllowLandingGear)
            {
                return(true);
            }
            var lgGrid = __instance.CubeGrid;

            if (lgGrid == entity || entity.MarkedForClose)
            {
                return(true);
            }

            var firstOwner = lgGrid != null && lgGrid.BigOwners.Count > 0 ? lgGrid.BigOwners[0] : __instance.OwnerId;

            if (firstOwner == 0)
            {
                __result = false;
                return(false);
            }
            long secondOwner;

            switch (entity)
            {
            case MyCubeGrid grid:
                secondOwner = grid.BigOwners[0];
                if (Config.Instance.PvpZones?.Count > 0)
                {
                    foreach (var zone in Config.Instance.PvpZones)
                    {
                        if (!zone.IsWithinZoneRadius(grid))
                        {
                            continue;
                        }
                        return(true);
                    }
                }

                break;

            case MyCubeBlock block:
                secondOwner = block.CubeGrid.BigOwners[0];
                if (Config.Instance.PvpZones?.Count > 0)
                {
                    foreach (var zone in Config.Instance.PvpZones)
                    {
                        if (!zone.IsWithinZoneRadius(block.CubeGrid))
                        {
                            continue;
                        }
                        return(true);
                    }
                }

                break;

            default:
                return(true);
            }

            if (secondOwner == firstOwner || secondOwner == 0)
            {
                return(true);
            }
            var attackerSteamId = MySession.Static.Players.TryGetSteamId(firstOwner);
            var targetSteamId   = MySession.Static.Players.TryGetSteamId(secondOwner);

            if (attackerSteamId == targetSteamId)
            {
                return(true);
            }
            if (Config.Instance.EnableFactionDamage)
            {
                var firstOwnerFaction  = MySession.Static.Factions.GetPlayerFaction(firstOwner);
                var secondOwnerFaction = MySession.Static.Factions.GetPlayerFaction(secondOwner);
                if (firstOwnerFaction != null && secondOwnerFaction != null &&
                    firstOwnerFaction == secondOwnerFaction)
                {
                    return(true);
                }
            }
            if (ConflictPairModule.InConflict(firstOwner, secondOwner, out var foundPair) && (foundPair == null || foundPair.CurrentConflictState == ConflictPairModule.ConflictState.Active))
            {
                return(true);
            }

            __result = false;
            return(false);
        }
 public MyDebugRenderComponentLandingGear(MyLandingGear landingGear)
     : base(landingGear)
 {
     m_langingGear = landingGear;
 }
 public LandingGearWrapper(MySlimBlock block) : base(block)
 {
     Block = (MyLandingGear)block.FatBlock;
 }
Ejemplo n.º 5
0
        public UnLander(Pathfinder pathfinder, PseudoBlock unlandBlock = null)
            : base(pathfinder)
        {
            this.m_unlandBlock = unlandBlock ?? m_navSet.Settings_Current.LandingBlock ?? m_navSet.LastLandingBlock;

            if (this.m_unlandBlock == null)
            {
                Log.DebugLog("No unland block", Logger.severity.INFO);
                return;
            }
            Log.DebugLog("Unland block is missing Block property", Logger.severity.FATAL, condition: this.m_unlandBlock.Block == null);

            IMyLandingGear asGear = m_unlandBlock.Block as IMyLandingGear;

            if (asGear != null)
            {
                m_destination.Entity = asGear.GetAttachedEntity();
                Log.DebugLog("m_destination.Entity: " + m_destination.Entity);
                if (m_destination.Entity == null)
                {
                    Log.DebugLog("Not attached: " + m_unlandBlock.Block.DisplayNameText, Logger.severity.INFO);
                    return;
                }
                Log.DebugLog("Got attached entity from Landing Gear : " + m_unlandBlock.Block.DisplayNameText, Logger.severity.DEBUG);
            }
            else
            {
                IMyShipConnector asConn = m_unlandBlock.Block as IMyShipConnector;
                if (asConn != null)
                {
                    Log.DebugLog("connector");
                    IMyShipConnector other = asConn.OtherConnector;
                    if (other == null)
                    {
                        Log.DebugLog("Not connected: " + m_unlandBlock.Block.DisplayNameText, Logger.severity.INFO);
                        return;
                    }
                    Log.DebugLog("Got attached connector from Connector : " + m_unlandBlock.Block.DisplayNameText, Logger.severity.DEBUG);
                    m_destination.Entity = other.CubeGrid;
                }
                else
                {
                    Log.DebugLog("Cannot unland block: " + m_unlandBlock.Block.DisplayNameText, Logger.severity.INFO);
                    m_unlandBlock.Block.EnableGameThread(false);
                }
            }

            MyLandingGear landingGear = this.m_unlandBlock.Block as MyLandingGear;

            if (landingGear != null)
            {
                MyAPIGateway.Utilities.TryInvokeOnGameThread(() => {
                    landingGear.Enabled  = true;
                    landingGear.AutoLock = true;
                });
            }

            m_detachOffset = m_unlandBlock.Block.GetPosition() - m_destination.Entity.GetPosition();

            //m_detachDirection = m_unlandBlock.WorldMatrix.Backward;
            //m_detachLength = 2f;
            //m_detatchedOffset = attachOffset + leaveDirection * (20f + m_navSet.Settings_Current.DestinationRadius);
            //Log.DebugLog("m_detatchedOffset: " + m_detatchedOffset, "UnLander()", Logger.severity.DEBUG);
            //m_detatchDirection = attachOffset + leaveDirection

            //Log.DebugLog("offset: " + m_detachOffset + ", direction: " + m_detachDirection);

            m_destination.Position = m_unlandBlock.WorldMatrix.Backward * 100f;

            m_navSet.Settings_Task_NavMove.NavigatorMover   = this;
            m_navSet.Settings_Task_NavMove.NavigatorRotator = this;
        }
 public LandingGearWrapper( MySlimBlock block )
     : base(block)
 {
     Block = (MyLandingGear)block.FatBlock;
 }