コード例 #1
0
        public ReactorEntity( CubeGridEntity parent, MyObjectBuilder_Reactor definition )
            : base(parent, definition)
        {
            m_Inventory = new InventoryEntity( definition.Inventory );

            m_lastInventoryRefresh = DateTime.Now;
        }
コード例 #2
0
		public PistonEntity( CubeGridEntity parent, MyObjectBuilder_PistonBase definition )
			: base( parent, definition )
		{
			m_velocity = definition.Velocity;
			m_minLimit = definition.MinLimit.GetValueOrDefault( 0 );
			m_maxLimit = definition.MaxLimit.GetValueOrDefault( 0 );
		}
コード例 #3
0
        public ReactorEntity( CubeGridEntity parent, MyObjectBuilder_Reactor definition, Object backingObject )
            : base(parent, definition, backingObject)
        {
            m_Inventory = new InventoryEntity( definition.Inventory, InternalGetReactorInventory( ) );

            m_lastInventoryRefresh = DateTime.Now;
        }
コード例 #4
0
		public LandingGearEntity(CubeGridEntity parent, MyObjectBuilder_LandingGear definition)
			: base(parent, definition)
		{
			m_isLocked = definition.IsLocked;
			m_autoLockEnabled = definition.AutoLock;
			m_brakeForce = definition.BrakeForce;
		}
コード例 #5
0
        public FunctionalBlockEntity( CubeGridEntity parent, MyObjectBuilder_FunctionalBlock definition, Object backingObject )
            : base(parent, definition, backingObject)
        {
            m_enabled = definition.Enabled;

            m_powerReceiver = new PowerReceiver( ActualObject, Parent.PowerManager, InternalGetPowerReceiver( ), new Func<float>( InternalPowerReceiverCallback ) );
        }
コード例 #6
0
        public ReactorEntity(CubeGridEntity parent, MyObjectBuilder_Reactor definition)
            : base(parent, definition)
        {
            m_Inventory = new InventoryEntity(definition.Inventory);
            m_powerProducer = new PowerProducer(Parent.PowerManager, null);

            m_lastInventoryRefresh = DateTime.Now;
        }
コード例 #7
0
        public ReactorEntity(CubeGridEntity parent, MyObjectBuilder_Reactor definition, Object backingObject)
            : base(parent, definition, backingObject)
        {
            m_Inventory = new InventoryEntity(definition.Inventory, InternalGetReactorInventory());
            m_powerProducer = new PowerProducer(Parent.PowerManager, ActualObject);

            m_lastInventoryRefresh = DateTime.Now;
        }
コード例 #8
0
		public LandingGearEntity(CubeGridEntity parent, MyObjectBuilder_LandingGear definition, Object backingObject)
			: base(parent, definition, backingObject)
		{
			m_isLocked = definition.IsLocked;
			m_autoLockEnabled = definition.AutoLock;
			m_brakeForce = definition.BrakeForce;

			m_landingNetManager = new LandingGearNetworkManager(this, GetLandingGearNetManager());
		}
コード例 #9
0
		public PistonEntity( CubeGridEntity parent, MyObjectBuilder_PistonBase definition, Object backingObject )
			: base( parent, definition, backingObject )
		{
			m_velocity = definition.Velocity;
			m_minLimit = definition.MinLimit.GetValueOrDefault( 0 );
			m_maxLimit = definition.MaxLimit.GetValueOrDefault( 0 );

			m_networkManager = new PistonNetworkManager( this, GetPistonNetworkManager( ) );
		}
コード例 #10
0
		public TurretBaseEntity(CubeGridEntity parent, MyObjectBuilder_TurretBase definition)
			: base(parent, definition)
		{
			m_inventory = new InventoryEntity(definition.Inventory);

			m_shootingRange = definition.Range;
			m_searchingRange = m_shootingRange + 100;

			m_targetMeteors = definition.TargetMeteors;
			m_targetMissiles = definition.TargetMissiles;
			m_targetMoving = definition.TargetMoving;
		}
コード例 #11
0
		public TurretBaseEntity(CubeGridEntity parent, MyObjectBuilder_TurretBase definition, Object backingObject)
			: base(parent, definition, backingObject)
		{
			m_turretNetworkManager = new TurretNetworkManager(this, GetNetworkManager());
			m_inventory = new InventoryEntity(definition.Inventory, GetTurretInventory());

			m_shootingRange = definition.Range;
			m_searchingRange = m_shootingRange + 100;

			m_targetMeteors = definition.TargetMeteors;
			m_targetMissiles = definition.TargetMissiles;
			m_targetMoving = definition.TargetMoving;
		}
コード例 #12
0
        public CubeBlockEntity(CubeGridEntity parent, MyObjectBuilder_CubeBlock definition, Object backingObject)
            : base(definition, backingObject)
        {
            m_parent = parent;

            //Only enable events for non-structural blocks, for now
            if (definition.EntityId != 0)
            {
                EntityEventManager.EntityEvent newEvent = new EntityEventManager.EntityEvent();
                newEvent.type = EntityEventManager.EntityEventType.OnCubeBlockCreated;
                newEvent.timestamp = DateTime.Now;
                newEvent.entity = this;
                if (m_parent.IsLoading)
                    newEvent.priority = 10;
                else
                    newEvent.priority = 1;
                EntityEventManager.Instance.AddEvent(newEvent);
            }
        }
コード例 #13
0
		public VirtualMassEntity( CubeGridEntity parent, MyObjectBuilder_VirtualMass definition )
			: base( parent, definition )
		{
		}
コード例 #14
0
 public BatteryBlockEntity(CubeGridEntity parent, MyObjectBuilder_BatteryBlock definition)
     : base(parent, definition)
 {
 }
コード例 #15
0
 public GatlingTurretEntity(CubeGridEntity parent, MyObjectBuilder_LargeGatlingTurret definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
 }
コード例 #16
0
 public DoorEntity(CubeGridEntity parent, MyObjectBuilder_Door definition)
     : base(parent, definition)
 {
 }
コード例 #17
0
 public LandingGearEntity(CubeGridEntity parent, MyObjectBuilder_LandingGear definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
 }
コード例 #18
0
		public InteriorTurretEntity( CubeGridEntity parent, MyObjectBuilder_InteriorTurret definition, Object backingObject )
			: base( parent, definition, backingObject )
		{
		}
コード例 #19
0
 public FunctionalBlockEntity( CubeGridEntity parent, MyObjectBuilder_FunctionalBlock definition )
     : base(parent, definition)
 {
     m_enabled = definition.Enabled;
 }
コード例 #20
0
 public RefineryEntity(CubeGridEntity parent, MyObjectBuilder_Refinery definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
 }
コード例 #21
0
 public SmallGatlingGunEntity(CubeGridEntity parent, MyObjectBuilder_SmallGatlingGun definition)
     : base(parent, definition)
 {
     m_inventory = new InventoryEntity(definition.Inventory);
 }
コード例 #22
0
 public BlockGroup(CubeGridEntity parent, MyObjectBuilder_BlockGroup definition)
     : base(definition)
 {
 }
コード例 #23
0
 public RefineryEntity(CubeGridEntity parent, MyObjectBuilder_Refinery definition)
     : base(parent, definition)
 {
 }
コード例 #24
0
 public ConveyorTubeEntity(CubeGridEntity parent, MyObjectBuilder_ConveyorConnector definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
 }
コード例 #25
0
 public ButtonPanelEntity(CubeGridEntity parent, MyObjectBuilder_RemoteControl definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
     //			_currentPlayerId = definition.CurrentPlayerId.GetValueOrDefault(0);
 }
コード例 #26
0
        // admin nobeacon scan
        public override bool HandleCommand(ulong userId, string[] words)
        {
            try
            {
                HashSet <IMyEntity> entities          = new HashSet <IMyEntity>();
                HashSet <IMyEntity> entitiesToConfirm = new HashSet <IMyEntity>();
                HashSet <IMyEntity> entitiesConnected = new HashSet <IMyEntity>();
                HashSet <IMyEntity> entitiesFound     = new HashSet <IMyEntity>();
                Wrapper.GameAction(() =>
                {
                    MyAPIGateway.Entities.GetEntities(entities, x => x is IMyCubeGrid);
                });

                foreach (IMyEntity entity in entities)
                {
                    if (!(entity is IMyCubeGrid))
                    {
                        continue;
                    }

                    IMyCubeGrid grid = (IMyCubeGrid)entity;
                    MyObjectBuilder_CubeGrid gridBuilder = CubeGrids.SafeGetObjectBuilder(grid);
                    if (gridBuilder == null)
                    {
                        continue;
                    }

                    bool found = false;
                    foreach (MyObjectBuilder_CubeBlock block in gridBuilder.CubeBlocks)
                    {
                        if (block.TypeId == typeof(MyObjectBuilder_Beacon))
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        entitiesToConfirm.Add(grid);
                    }
                }

                CubeGrids.GetGridsUnconnected(entitiesFound, entitiesToConfirm);

                foreach (IMyEntity entity in entitiesFound)
                {
                    CubeGridEntity gridEntity = (CubeGridEntity)GameEntityManager.GetEntity(entity.EntityId);
                    if (gridEntity == null)
                    {
                        Log.Info("A found entity gridEntity was null!");
                        continue;
                    }
                    Communication.SendPrivateInformation(userId, string.Format("Found entity '{0}' ({1}) at {2} with no beacon.", gridEntity.Name, gridEntity.EntityId, General.Vector3DToString(entity.GetPosition())));
                }

                Communication.SendPrivateInformation(userId, string.Format("Found {0} grids with no beacons", entitiesFound.Count));
            }
            catch (Exception ex)
            {
                Log.Info(string.Format("Scan error: {0}", ex.ToString()));
            }

            return(true);
        }
コード例 #27
0
 public CargoContainerEntity(CubeGridEntity parent, MyObjectBuilder_CargoContainer definition)
     : base(parent, definition)
 {
     m_Inventory = new InventoryEntity(definition.Inventory);
 }
コード例 #28
0
 public SmallGatlingGunEntity(CubeGridEntity parent, MyObjectBuilder_SmallGatlingGun definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
     m_inventory = new InventoryEntity(definition.Inventory, GetInventory( ));
 }
コード例 #29
0
 public virtual void OnCubeGridDeleted(CubeGridEntity entity)
 {
 }
コード例 #30
0
 public OreDetectorEntity(CubeGridEntity parent, MyObjectBuilder_OreDetector definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
     m_broadcastUsingAntennas = definition.BroadcastUsingAntennas;
     m_detectionRadius        = definition.DetectionRadius;
 }
コード例 #31
0
		public ShipToolBaseEntity(CubeGridEntity parent, MyObjectBuilder_ShipToolBase definition)
			: base(parent, definition)
		{
			m_inventory = new InventoryEntity(definition.Inventory);
		}
コード例 #32
0
 public MedicalRoomEntity(CubeGridEntity parent, MyObjectBuilder_MedicalRoom definition)
     : base(parent, definition)
 {
 }
コード例 #33
0
 public InteriorLightEntity(CubeGridEntity parent, MyObjectBuilder_InteriorLight definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
 }
コード例 #34
0
 public MedicalRoomEntity(CubeGridEntity parent, MyObjectBuilder_MedicalRoom definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
 }
コード例 #35
0
 public CameraBlockEntity(CubeGridEntity parent, MyObjectBuilder_CameraBlock definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
     m_isActive = definition.IsActive;
 }
コード例 #36
0
        // /admin movefrom x y z x y z radius
        public override bool HandleCommand(ulong userId, string[] words)
        {
            if (words.Count() != 7 && words.Count() != 0)
            {
                return(false);
            }

            if (words.Count() != 7)
            {
                Communication.SendPrivateInformation(userId, GetHelp());
                return(true);
            }

            // Test Input
            float test = 0;

            for (int r = 0; r < 7; r++)
            {
                if (!float.TryParse(words[r], out test))
                {
                    Communication.SendPrivateInformation(userId, string.Format("The value at position {0} - '{1}' is invalid.  Please try the command again.", r + 1, words[r]));
                    return(true);
                }
            }

            Vector3D startPosition = new Vector3(float.Parse(words[0]), float.Parse(words[1]), float.Parse(words[2]));
            Vector3D movePosition  = new Vector3(float.Parse(words[3]), float.Parse(words[4]), float.Parse(words[5]));
            Vector3D difference    = startPosition - movePosition;
            float    radius        = float.Parse(words[6]);

            Communication.SendPrivateInformation(userId, string.Format("Moving all grids in a radius of {0} near {1} to {2}", radius, General.Vector3DToString(startPosition), General.Vector3DToString(movePosition)));

            List <MyObjectBuilder_CubeGrid> gridsToMove = new List <MyObjectBuilder_CubeGrid>();
            BoundingSphereD  sphere         = new BoundingSphereD(startPosition, radius);
            List <IMyEntity> entitiesToMove = MyAPIGateway.Entities.GetEntitiesInSphere(ref sphere);

//			Wrapper.GameAction(() =>
//			{
            foreach (IMyEntity entity in entitiesToMove)
            {
                if (!(entity is IMyCubeGrid))
                {
                    continue;
                }

                Communication.SendPrivateInformation(userId, string.Format("Moving '{0}' from {1} to {2}", entity.DisplayName, General.Vector3DToString(entity.GetPosition()), General.Vector3DToString(entity.GetPosition() + difference)));

                gridsToMove.Add((MyObjectBuilder_CubeGrid)entity.GetObjectBuilder());
                //MyAPIGateway.Entities.RemoveEntity(entity);
                CubeGridEntity gridEntity = new CubeGridEntity((MyObjectBuilder_CubeGrid)entity.GetObjectBuilder(), entity);
                gridEntity.Dispose();
            }
//			});

            Logging.WriteLineAndConsole("Entities Removed ... pausing");
            Thread.Sleep(5000);
            Logging.WriteLineAndConsole("Removing entities from closed entities");

            Wrapper.GameAction(() =>
            {
                foreach (IMyEntity entity in entitiesToMove)
                {
                    if (!(entity is IMyCubeGrid))
                    {
                        continue;
                    }

                    Logging.WriteLineAndConsole(string.Format("Removing '{0}' for move", entity.DisplayName));
                    MyAPIGateway.Entities.RemoveFromClosedEntities(entity);
                }
            });

            Thread.Sleep(10000);

            Wrapper.GameAction(() =>
            {
                foreach (MyObjectBuilder_CubeGrid grid in gridsToMove)
                {
                    grid.PositionAndOrientation = new MyPositionAndOrientation(grid.PositionAndOrientation.Value.Position + difference, grid.PositionAndOrientation.Value.Forward, grid.PositionAndOrientation.Value.Up);
                    //Logging.WriteLineAndConsole(string.Format("Adding '{0}' for move", grid.DisplayName));
                    Communication.SendPrivateInformation(userId, string.Format("Adding grid '{0}' back to world.", grid.DisplayName));
                    SectorObjectManager.Instance.AddEntity(new CubeGridEntity(grid));
                    Thread.Sleep(1000);
                }
            });

            Communication.SendPrivateInformation(userId, string.Format("Moved {0} grids", gridsToMove.Count));

            return(true);
        }
コード例 #37
0
 public BeaconEntity(CubeGridEntity parent, MyObjectBuilder_Beacon definition)
     : base(parent, definition)
 {
 }
コード例 #38
0
        // admin deletearea x y z radius
        public override bool HandleCommand(ulong userId, string[] words)
        {
            if (words.Count() > 3)
            {
                return(false);
            }

            if (words.Count() == 0)
            {
                Communication.SendPrivateInformation(userId, GetHelp());
                return(true);
            }

            int days = -1;

            if (!int.TryParse(words[0], out days) || days < 0)
            {
                Communication.SendPrivateInformation(userId, string.Format("Invalid argument.  Days argument must be an integer that is 0 or greater."));
                return(true);
            }

            // Just assume that anything after the days is going to "ignorenologin"
            bool removeNoLoginInformation = true;
            bool removeOwnerless          = true;

            if (words.Count() > 1)
            {
                foreach (string word in words)
                {
                    if (word.ToLower() == "ignorenologin")
                    {
                        removeNoLoginInformation = false;
                    }
                    if (word.ToLower() == "ignoreownerless")
                    {
                        removeOwnerless = false;
                    }
                }
            }

            Communication.SendPrivateInformation(userId, string.Format("Scanning for grids with owners that haven't logged in {0} days.  (Must Have Login Info={1})", days, removeNoLoginInformation));

            HashSet <IMyEntity> entities = new HashSet <IMyEntity>();

            Wrapper.GameAction(() =>
            {
                MyAPIGateway.Entities.GetEntities(entities, x => x is IMyCubeGrid);
            });

            HashSet <IMyEntity> entitiesFound = new HashSet <IMyEntity>();

            foreach (IMyEntity entity in entities)
            {
                if (!(entity is IMyCubeGrid))
                {
                    continue;
                }

                IMyCubeGrid              grid        = (IMyCubeGrid)entity;
                CubeGridEntity           gridEntity  = (CubeGridEntity)GameEntityManager.GetEntity(grid.EntityId);
                MyObjectBuilder_CubeGrid gridBuilder = CubeGrids.SafeGetObjectBuilder(grid);
                if (gridBuilder == null)
                {
                    continue;
                }

                // This entity is protected by whitelist
                if (PluginSettings.Instance.LoginEntityWhitelist.Length > 0 && PluginSettings.Instance.LoginEntityWhitelist.Contains(grid.EntityId.ToString()))
                {
                    continue;
                }

                if (CubeGrids.GetAllOwners(gridBuilder).Count < 1 && removeOwnerless)
                {
                    Communication.SendPrivateInformation(userId, string.Format("Found entity '{0}' ({1}) not owned by anyone.", gridEntity.Name, entity.EntityId));
                    entitiesFound.Add(entity);
                    continue;
                }

                foreach (long player in CubeGrids.GetBigOwners(gridBuilder))
                {
                    // This playerId is protected by whitelist
                    if (PluginSettings.Instance.LoginPlayerIdWhitelist.Length > 0 && PluginSettings.Instance.LoginPlayerIdWhitelist.Contains(player.ToString()))
                    {
                        continue;
                    }

                    MyObjectBuilder_Checkpoint.PlayerItem checkItem = PlayerMap.Instance.GetPlayerItemFromPlayerId(player);
                    if (checkItem.IsDead || checkItem.Name == "")
                    {
                        Communication.SendPrivateInformation(userId, string.Format("Found entity '{0}' ({1}) owned by dead player - ID: {2}", gridEntity.Name, entity.EntityId, player));
                        entitiesFound.Add(entity);
                        continue;
                    }

                    PlayerItem item = Players.Instance.GetPlayerById(player);
                    if (item == null)
                    {
                        if (removeNoLoginInformation)
                        {
                            Communication.SendPrivateInformation(userId, string.Format("Found entity '{0}' ({1}) owned by a player with no login info: {2}", gridEntity.Name, entity.EntityId, checkItem.Name));
                            entitiesFound.Add(entity);
                        }
                    }
                    else if (item.LastLogin < DateTime.Now.AddDays(days * -1))
                    {
                        Communication.SendPrivateInformation(userId, string.Format("Found entity '{0}' ({1}) owned by inactive player: {2}", gridEntity.Name, entity.EntityId, PlayerMap.Instance.GetPlayerItemFromPlayerId(player).Name));
                        entitiesFound.Add(entity);
                    }
                }
            }

            Communication.SendPrivateInformation(userId, string.Format("Found {0} grids owned by inactive users", entitiesFound.Count));

            foreach (IMyEntity entity in entitiesFound)
            {
                if (!(entity is IMyCubeGrid))
                {
                    continue;
                }

                CubeGridEntity gridEntity = new CubeGridEntity((MyObjectBuilder_CubeGrid)entity.GetObjectBuilder(), entity);
                gridEntity.Dispose();
            }

            Communication.SendPrivateInformation(userId, string.Format("Removed {0} grids owned by inactive users", entitiesFound.Count));
            return(true);
        }
コード例 #39
0
		public GyroEntity( CubeGridEntity parent, MyObjectBuilder_Gyro definition, Object backingObject )
			: base( parent, definition, backingObject )
		{
			m_networkManager = new GyroNetworkManager( this, InternalGetGyroNetworkManager( ) );
		}
コード例 #40
0
		public CubeBlockEntity( CubeGridEntity parent, MyObjectBuilder_CubeBlock definition, Object backingObject )
			: base( definition, backingObject )
		{
			m_parent = parent;

			EntityEventManager.EntityEvent newEvent = new EntityEventManager.EntityEvent( );
			newEvent.type = EntityEventManager.EntityEventType.OnCubeBlockCreated;
			newEvent.timestamp = DateTime.Now;
			newEvent.entity = this;
			if ( m_parent.IsLoading )
			{
				newEvent.priority = 10;
			}
			else if ( EntityId != 0 )
			{
				newEvent.priority = 1;
			}
			else
			{
				newEvent.priority = 2;
			}
			EntityEventManager.Instance.AddEvent( newEvent );

			if ( EntityId != 0 )
			{
				GameEntityManager.AddEntity( EntityId, this );
			}

			m_buildPercent = definition.BuildPercent;
			m_integrityPercent = definition.IntegrityPercent;
			m_owner = definition.Owner;
			m_shareMode = definition.ShareMode;
		}
コード例 #41
0
		public ConveyorTubeEntity(CubeGridEntity parent, MyObjectBuilder_ConveyorConnector definition, Object backingObject)
			: base(parent, definition, backingObject)
		{
		}
コード例 #42
0
		public ConveyorLine( CubeGridEntity parent, MyObjectBuilder_ConveyorLine definition )
			: base( definition )
		{
		}
コード例 #43
0
		public VirtualMassEntity( CubeGridEntity parent, MyObjectBuilder_VirtualMass definition, Object backingObject )
			: base( parent, definition, backingObject )
		{
		}
コード例 #44
0
 public CubeBlockManager(CubeGridEntity parent, Object backingSource, string backingSourceMethodName)
     : base(backingSource, backingSourceMethodName, InternalBackingType.Hashset)
 {
     m_isLoading = true;
     m_parent = parent;
 }
コード例 #45
0
 public CargoContainerEntity(CubeGridEntity parent, MyObjectBuilder_CargoContainer definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
     m_Inventory = new InventoryEntity(definition.Inventory, InternalGetContainerInventory());
 }
コード例 #46
0
 public AssemblerEntity(CubeGridEntity parent, MyObjectBuilder_Assembler definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
 }
コード例 #47
0
 public virtual void OnCubeGridCreated(CubeGridEntity entity)
 {
 }
コード例 #48
0
 public GravityGeneratorEntity(CubeGridEntity parent, MyObjectBuilder_GravityGenerator definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
 }
コード例 #49
0
		public LightEntity(CubeGridEntity parent, MyObjectBuilder_LightingBlock definition, Object backingObject)
			: base(parent, definition, backingObject)
		{
		}
コード例 #50
0
 public MergeBlockEntity(CubeGridEntity parent, MyObjectBuilder_MergeBlock definition)
     : base(parent, definition)
 {
 }
コード例 #51
0
		public ShipToolBaseEntity(CubeGridEntity parent, MyObjectBuilder_ShipToolBase definition, Object backingObject)
			: base(parent, definition, backingObject)
		{
			m_inventory = new InventoryEntity(definition.Inventory, InternalGetContainerInventory());
		}
コード例 #52
0
 public DoorEntity(CubeGridEntity parent, MyObjectBuilder_Door definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
 }
コード例 #53
0
 public ShipToolBaseEntity(CubeGridEntity parent, MyObjectBuilder_ShipToolBase definition)
     : base(parent, definition)
 {
     m_inventory = new InventoryEntity(definition.Inventory);
 }
コード例 #54
0
 public InteriorLightEntity(CubeGridEntity parent, MyObjectBuilder_InteriorLight definition)
     : base(parent, definition)
 {
 }
コード例 #55
0
		public CubeBlockEntity( CubeGridEntity parent, MyObjectBuilder_CubeBlock definition )
			: base( definition )
		{
			m_parent = parent;

			m_buildPercent = definition.BuildPercent;
			m_integrityPercent = definition.IntegrityPercent;
			m_owner = definition.Owner;
			m_shareMode = definition.ShareMode;
		}
コード例 #56
0
 public ShipToolBaseEntity(CubeGridEntity parent, MyObjectBuilder_ShipToolBase definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
     m_inventory = new InventoryEntity(definition.Inventory, InternalGetContainerInventory( ));
 }
コード例 #57
0
 public CubeBlockManager(CubeGridEntity parent)
 {
     m_isLoading = true;
     m_parent = parent;
 }
コード例 #58
0
 public MissileTurretEntity(CubeGridEntity parent, MyObjectBuilder_LargeMissileTurret definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
 }
コード例 #59
0
 public CubeBlockEntity(CubeGridEntity parent, MyObjectBuilder_CubeBlock definition)
     : base(definition)
 {
     m_parent = parent;
 }
コード例 #60
0
        public void SpawnCargoShipGroup(Vector3 startPosition, Vector3 stopPosition, ulong remoteUserId = 0)
        {
            try
            {
                //Calculate lowest and highest frequencies
                float lowestFrequency  = 999999;
                float highestFrequency = 0;
                foreach (MySpawnGroupDefinition entry in MyDefinitionManager.Static.GetSpawnGroupDefinitions( ))
                {
                    if (entry.Frequency < lowestFrequency)
                    {
                        lowestFrequency = entry.Frequency;
                    }
                    if (entry.Frequency > highestFrequency)
                    {
                        highestFrequency = entry.Frequency;
                    }
                }
                if (lowestFrequency <= 0)
                {
                    lowestFrequency = 1;
                }

                //Get a list of which groups *could* spawn
                Random random       = new Random((int)DateTime.Now.ToBinary( ));
                double randomChance = random.NextDouble( );
                randomChance = randomChance * (highestFrequency / lowestFrequency);
                List <MySpawnGroupDefinition> possibleGroups = new List <MySpawnGroupDefinition>( );
                foreach (MySpawnGroupDefinition entry in MyDefinitionManager.Static.GetSpawnGroupDefinitions( ))
                {
                    if (entry.Frequency >= randomChance)
                    {
                        possibleGroups.Add(entry);
                    }
                }

                //Determine which group *will* spawn
                randomChance = random.NextDouble( );
                int randomShipIndex = Math.Max(0, Math.Min((int)Math.Round(randomChance * possibleGroups.Count, 0), possibleGroups.Count - 1));
                MySpawnGroupDefinition randomSpawnGroup = possibleGroups[randomShipIndex];

                ChatManager.Instance.SendPrivateChatMessage(remoteUserId, string.Format("Spawning cargo group '{0}' ...", randomSpawnGroup.DisplayNameText));

                //Spawn the ships in the group
                Matrix orientation = Matrix.CreateLookAt(startPosition, stopPosition, new Vector3(0, 1, 0));
                foreach (MySpawnGroupDefinition.SpawnGroupPrefab entry in randomSpawnGroup.Prefabs)
                {
                    MyPrefabDefinition matchedPrefab = null;
                    foreach (var prefabEntry in MyDefinitionManager.Static.GetPrefabDefinitions( ))
                    {
                        MyPrefabDefinition prefabDefinition = prefabEntry.Value;
                        if (prefabDefinition.Id.SubtypeId.ToString( ) == entry.SubtypeId)
                        {
                            matchedPrefab = prefabDefinition;
                            break;
                        }
                    }
                    if (matchedPrefab == null)
                    {
                        continue;
                    }

                    //TODO - Build this to iterate through all cube grids in the prefab
                    MyObjectBuilder_CubeGrid objectBuilder = matchedPrefab.CubeGrids[0];

                    //Create the ship
                    CubeGridEntity cubeGrid = new CubeGridEntity(objectBuilder);

                    //Set the ship position and orientation
                    Vector3 shipPosition = Vector3.Transform(entry.Position, orientation) + startPosition;
                    orientation.Translation = shipPosition;
                    MyPositionAndOrientation newPositionOrientation = new MyPositionAndOrientation(orientation);
                    cubeGrid.PositionAndOrientation = newPositionOrientation;

                    //Set the ship velocity
                    //Speed is clamped between 1.0f and the max cube grid speed
                    Vector3 travelVector = stopPosition - startPosition;
                    travelVector.Normalize( );
                    Vector3 shipVelocity = travelVector * Math.Min(cubeGrid.MaxLinearVelocity, Math.Max(1.0f, entry.Speed));
                    cubeGrid.LinearVelocity = shipVelocity;

                    cubeGrid.IsDampenersEnabled = false;

                    foreach (MyObjectBuilder_CubeBlock cubeBlock in cubeGrid.BaseCubeBlocks)
                    {
                        //Set the beacon names
                        if (cubeBlock.TypeId == typeof(MyObjectBuilder_Beacon))
                        {
                            MyObjectBuilder_Beacon beacon = (MyObjectBuilder_Beacon)cubeBlock;
                            beacon.CustomName = entry.BeaconText;
                        }

                        //Set the owner of every block
                        //TODO - Find out if setting to an arbitrary non-zero works for this
                        //cubeBlock.Owner = PlayerMap.Instance.GetServerVirtualPlayerId();
                        cubeBlock.Owner     = 0;
                        cubeBlock.ShareMode = MyOwnershipShareModeEnum.Faction;
                    }

                    //And add the ship to the world
                    SectorObjectManager.Instance.AddEntity(cubeGrid);
                }

                ChatManager.Instance.SendPrivateChatMessage(remoteUserId, string.Format("Cargo group '{0}' spawned with {1} ships at {2}", randomSpawnGroup.DisplayNameText, randomSpawnGroup.Prefabs.Count, startPosition));
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog.WriteLine(ex);
            }
        }