Exemplo n.º 1
0
        private static bool CheckConcealForce(IMyCubeGrid grid, ulong steamId)
        {
            List <IMySlimBlock> blocks = new List <IMySlimBlock>();

            // Live dangerously
            grid.GetBlocks(blocks, x => x.FatBlock != null);
            foreach (IMySlimBlock block in blocks)
            {
                IMyCubeBlock cubeBlock = block.FatBlock;

                if (cubeBlock.BlockDefinition.TypeId == typeof(MyObjectBuilder_MedicalRoom))
                {
                    MyObjectBuilder_MedicalRoom medical = (MyObjectBuilder_MedicalRoom)cubeBlock.GetObjectBuilderCubeBlock();

                    if (!medical.Enabled)
                    {
                        continue;
                    }

                    Sandbox.ModAPI.Ingame.IMyTerminalBlock terminalBlock = (Sandbox.ModAPI.Ingame.IMyTerminalBlock)cubeBlock;
                    long playerId = PlayerMap.Instance.GetFastPlayerIdFromSteamId(steamId);
                    if (medical.Owner == playerId || (medical.ShareMode == MyOwnershipShareModeEnum.Faction && Player.CheckPlayerSameFaction(medical.Owner, playerId)))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
 public static void SetUseConveyorSystem(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block, bool use)
 {
     if (block is IMyInventoryOwner)
     {
         ((IMyInventoryOwner)block).UseConveyorSystem = use;
     }
 }
Exemplo n.º 3
0
        public void listActions(Sandbox.ModAPI.Ingame.IMyTerminalBlock block, Logger log, Config config)
        {
            List <ITerminalAction> actions = new List <ITerminalAction>();

            block.GetActions(actions);
            for (int i = 0; i < actions.Count; i++)
            {
                log.log(config.statusPanel, actions[i].Name.ToString() + "(" + actions[i].Id + ")", ErrorSeverity.Notice);
            }
        }
Exemplo n.º 4
0
        public void listProperties(Sandbox.ModAPI.Ingame.IMyTerminalBlock block, Logger log, Config config)
        {
            List <ITerminalProperty> properties = new List <ITerminalProperty>();

            block.GetProperties(properties);
            for (int i = 0; i < properties.Count; i++)
            {
                log.log(config.statusPanel, properties[i].Id, ErrorSeverity.Notice);
            }
        }
Exemplo n.º 5
0
        public IMyTerminalBlock GetTargetKeyAttackPoint(IMyCubeGrid grid)
        {
            TargetDetails    details;
            IMyTerminalBlock block = null;

            if (targets.TryGetValue(grid, out details))
            {
                block = details.GetTargetKeyAttackPoint();
            }
            return(block);
        }
Exemplo n.º 6
0
 public static VRage.ModAPI.Ingame.IMyInventory GetInventory(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block, int index)
 {
     if (block is IMyInventoryOwner)
     {
         return(((IMyInventoryOwner)block).GetInventory(index));
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 7
0
        public static int GetInventoryCount(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block)
        {
            var entity = block as MyEntity;

            if (entity == null)
            {
                return(0);
            }

            return(entity.InventoryCount);
        }
Exemplo n.º 8
0
 public static int GetInventoryCount(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block)
 {
     if (block is IMyInventoryOwner)
     {
         return(((IMyInventoryOwner)block).InventoryCount);
     }
     else
     {
         return(0);
     }
 }
Exemplo n.º 9
0
 public static bool GetUseConveyorSystem(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block)
 {
     if (block is IMyInventoryOwner)
     {
         return(((IMyInventoryOwner)block).UseConveyorSystem);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 10
0
 public static Sandbox.ModAPI.Interfaces.IMyInventory GetInventory(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block, int index)
 {
     if (block.HasInventory())
     {
         return(((Sandbox.ModAPI.Interfaces.IMyInventoryOwner)block).GetInventory(index));
     }
     else
     {
         return(null);
     }
 }
 public static void SetCustomName(Sandbox.ModAPI.Ingame.IMyTerminalBlock terminalBlock, string text)
 {
     try
     {
         StringBuilder newCustomName = new StringBuilder(text);
         InvokeStaticMethod(terminalBlock.GetType(), TerminalBlockBroadcastCustomNameMethod, new object[] { terminalBlock, newCustomName });
     }
     catch (Exception ex)
     {
         LogManager.APILog.WriteLineAndConsole(string.Format("SetCustomName(): {0}", ex.ToString()));
     }
 }
Exemplo n.º 12
0
        public static bool HasInventory(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block)
        {
            var entity = block as MyEntity;

            if (entity == null)
            {
                return(false);
            }
            if (!(block is IMyInventoryOwner))
            {
                return(false);
            }

            return(entity.HasInventory);
        }
Exemplo n.º 13
0
        public static VRage.Game.ModAPI.Ingame.IMyInventory GetInventory(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block, int index)
        {
            var entity = block as MyEntity;

            if (entity == null)
            {
                return(null);
            }

            if (!entity.HasInventory)
            {
                return(null);
            }

            return(entity.GetInventoryBase(index) as IMyInventory);
        }
Exemplo n.º 14
0
 private static bool TAPI_IsShieldUp(Sandbox.ModAPI.Ingame.IMyTerminalBlock arg) => TAPI_IsShieldUp(arg as IMyTerminalBlock);
Exemplo n.º 15
0
 public static bool HasInventory(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block)
 {
     return(block is Sandbox.ModAPI.Interfaces.IMyInventoryOwner);
 }
Exemplo n.º 16
0
 public static void ApplyAction(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block, string actionName, List <TerminalActionParameter> parameters)
 {
     block.GetActionWithName(actionName).Apply(block, parameters);
 }
Exemplo n.º 17
0
 public static bool HasAction(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block, string actionName)
 {
     return(block.GetActionWithName(actionName) != null);
 }
Exemplo n.º 18
0
 private static double TAPI_GetDistanceToShield(Sandbox.ModAPI.Ingame.IMyTerminalBlock arg1, Vector3D arg2) => TAPI_GetDistanceToShield(arg1 as IMyTerminalBlock, arg2);
Exemplo n.º 19
0
 public static void ApplyAction(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block, string actionName)
 {
     block.GetActionWithName(actionName).Apply(block);
 }
Exemplo n.º 20
0
        private static bool CheckConcealBlockRules(IMyCubeGrid grid, List <IMyPlayer> players)
        {
            List <IMySlimBlock> blocks = new List <IMySlimBlock>();

            // Live dangerously
            grid.GetBlocks(blocks, x => x.FatBlock != null);
            //CubeGrids.GetAllConnectedBlocks(m_processedGrids, grid, blocks, x => x.FatBlock != null);

            int beaconCount = 0;

            //bool found = false;
            //bool powered = false;
            foreach (IMySlimBlock block in blocks)
            {
                IMyCubeBlock cubeBlock = block.FatBlock;

                if (cubeBlock.BlockDefinition.TypeId == typeof(MyObjectBuilder_Beacon))
                {
                    Sandbox.ModAPI.Ingame.IMyBeacon beacon = (Sandbox.ModAPI.Ingame.IMyBeacon)cubeBlock;
                    //MyObjectBuilder_Beacon beacon = (MyObjectBuilder_Beacon)cubeBlock.GetObjectBuilderCubeBlock();
                    beaconCount++;
                    // Keep this return here, as 4 beacons always means true
                    if (beaconCount >= 4)
                    {
                        return(true);
                    }

                    if (!beacon.Enabled)
                    {
                        continue;
                    }

                    Sandbox.ModAPI.Ingame.IMyTerminalBlock terminalBlock = (Sandbox.ModAPI.Ingame.IMyTerminalBlock)cubeBlock;
//					Console.WriteLine("Found: {0} {1} {2}", beacon.BroadcastRadius, terminalBlock.IsWorking, terminalBlock.IsFunctional);
                    //if (!terminalBlock.IsWorking)
                    //{
//						continue;
                    //}

                    foreach (IMyPlayer player in players)
                    {
                        double distance = 0d;
                        if (Entity.GetDistanceBetweenPointAndPlayer(grid.GetPosition(), player, out distance))
                        {
                            if (distance < beacon.Radius)
                            {
//								Console.WriteLine("Not concealed due to broadcast radius");
                                //found = true;
                                //break;
                                return(true);
                            }
                        }
                    }
                }

                if (cubeBlock.BlockDefinition.TypeId == typeof(MyObjectBuilder_RadioAntenna))
                {
                    //MyObjectBuilder_RadioAntenna antenna = (MyObjectBuilder_RadioAntenna)cubeBlock.GetObjectBuilderCubeBlock();
                    Sandbox.ModAPI.Ingame.IMyRadioAntenna antenna = (Sandbox.ModAPI.Ingame.IMyRadioAntenna)cubeBlock;

                    if (!antenna.Enabled)
                    {
                        continue;
                    }

                    Sandbox.ModAPI.Ingame.IMyTerminalBlock terminalBlock = (Sandbox.ModAPI.Ingame.IMyTerminalBlock)cubeBlock;
                    //if (!terminalBlock.IsWorking)
                    //	continue;

                    foreach (IMyPlayer player in players)
                    {
                        double distance = 0d;
                        if (Entity.GetDistanceBetweenPointAndPlayer(grid.GetPosition(), player, out distance))
                        {
                            if (distance < antenna.Radius)
                            {
//								Console.WriteLine("Not concealed due to antenna broadcast radius");
                                //found = true;
                                //break;
                                return(true);
                            }
                        }
                    }
                }

                if (cubeBlock.BlockDefinition.TypeId == typeof(MyObjectBuilder_MedicalRoom))
                {
                    //MyObjectBuilder_MedicalRoom medical = (MyObjectBuilder_MedicalRoom)cubeBlock.GetObjectBuilderCubeBlock();
                    Sandbox.ModAPI.Ingame.IMyMedicalRoom medical = (Sandbox.ModAPI.Ingame.IMyMedicalRoom)cubeBlock;

                    if (!medical.Enabled)
                    {
                        continue;
                    }

                    Sandbox.ModAPI.Ingame.IMyFunctionalBlock functionalBlock = (Sandbox.ModAPI.Ingame.IMyFunctionalBlock)cubeBlock;
                    //if (!terminalBlock.IsWorking)
                    //	continue;

                    if (PluginSettings.Instance.DynamicConcealIncludeMedBays)
                    {
                        lock (m_online)
                        {
                            foreach (ulong connectedPlayer in m_online)
                            {
                                //if (PlayerMap.Instance.GetPlayerIdsFromSteamId(connectedPlayer).Count < 1)
                                //continue;

                                //long playerId = PlayerMap.Instance.GetPlayerIdsFromSteamId(connectedPlayer).First();
                                long playerId = PlayerMap.Instance.GetFastPlayerIdFromSteamId(connectedPlayer);

                                if (functionalBlock.OwnerId == playerId || (functionalBlock.GetUserRelationToOwner(playerId) == Sandbox.Common.MyRelationsBetweenPlayerAndBlock.FactionShare))
                                //if (functionalBlock.Owner == playerId || (functionalBlock.ShareMode == MyOwnershipShareModeEnum.Faction && Player.CheckPlayerSameFaction(functionalBlock.Owner, playerId)))
                                //if (medical.HasPlayerAccess(playerId))
                                {
                                    return(true);
                                }
                            }
                        }

                        /*
                         * foreach (ulong connectedPlayer in PlayerManager.Instance.ConnectedPlayers)
                         * {
                         *      //if (PlayerMap.Instance.GetPlayerIdsFromSteamId(connectedPlayer).Count < 1)
                         *              //continue;
                         *
                         *      //long playerId = PlayerMap.Instance.GetPlayerIdsFromSteamId(connectedPlayer).First();
                         *      long playerId = PlayerMap.Instance.GetFastPlayerIdFromSteamId(connectedPlayer);
                         *      //if (medical.Owner == playerId || (medical.ShareMode == MyOwnershipShareModeEnum.Faction && Player.CheckPlayerSameFaction(medical.Owner, playerId)))
                         *      if(medical.HasPlayerAccess(playerId))
                         *      {
                         *              return true;
                         *      }
                         * }
                         */
                    }
                    else
                    {
                        return(true);
                    }
                }

                if (cubeBlock.BlockDefinition.TypeId == typeof(MyObjectBuilder_Refinery) || cubeBlock.BlockDefinition.TypeId == typeof(MyObjectBuilder_Assembler))
                {
                    //MyObjectBuilder_ProductionBlock production = (MyObjectBuilder_ProductionBlock)cubeBlock.GetObjectBuilderCubeBlock();
                    Sandbox.ModAPI.Ingame.IMyProductionBlock production = (Sandbox.ModAPI.Ingame.IMyProductionBlock)cubeBlock;
                    if (!production.Enabled)
                    {
                        continue;
                    }

                    if (production.IsProducing)
                    {
                        return(true);
                    }
                }

                foreach (string subType in PluginSettings.Instance.DynamicConcealIgnoreSubTypeList)
                {
                    if (cubeBlock.BlockDefinition.SubtypeName.Contains(subType))
                    {
//						Console.WriteLine("Not concealed due subtype");
                        //found = true;
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 21
0
 private static Vector3D?TAPI_GetClosestShieldPoint(Sandbox.ModAPI.Ingame.IMyTerminalBlock arg1, Vector3D arg2) => TAPI_GetClosestShieldPoint(arg1 as IMyTerminalBlock, arg2);
Exemplo n.º 22
0
 public static bool HasAction(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block, string Action)
 {
     return(!(block.GetActionWithName(Action) == null));
 }
Exemplo n.º 23
0
 public static bool HasInventory(this Sandbox.ModAPI.Ingame.IMyTerminalBlock block)
 {
     return(((IMyInventoryOwner)block).HasInventory);
 }
Exemplo n.º 24
0
 private static bool TAPI_EntityBypass(Sandbox.ModAPI.Ingame.IMyTerminalBlock arg1, VRage.Game.ModAPI.Ingame.IMyEntity arg2, bool arg3) => TAPI_EntityBypass(arg1 as IMyTerminalBlock, arg2 as IMyEntity, arg3);
Exemplo n.º 25
0
 private static float TAPI_GetMaxHpCap(Sandbox.ModAPI.Ingame.IMyTerminalBlock arg) => TAPI_GetMaxHpCap(arg as IMyTerminalBlock);
Exemplo n.º 26
0
 private static int TAPI_HpToChargeRatio(Sandbox.ModAPI.Ingame.IMyTerminalBlock arg) => TAPI_HpToChargeRatio(arg as IMyTerminalBlock);
Exemplo n.º 27
0
 private static float TAPI_GetCharge(Sandbox.ModAPI.Ingame.IMyTerminalBlock arg) => TAPI_GetCharge(arg as IMyTerminalBlock);
Exemplo n.º 28
0
 private static float TAPI_GetPowerUsed(Sandbox.ModAPI.Ingame.IMyTerminalBlock arg) => TAPI_GetPowerUsed(arg as IMyTerminalBlock);
Exemplo n.º 29
0
 private static int TAPI_GetShieldHeatLevel(Sandbox.ModAPI.Ingame.IMyTerminalBlock arg) => TAPI_GetShieldHeatLevel(arg as IMyTerminalBlock);
Exemplo n.º 30
0
 private static string TAPI_ShieldStatus(Sandbox.ModAPI.Ingame.IMyTerminalBlock arg) => TAPI_ShieldStatus(arg as IMyTerminalBlock);