public override bool Invoke(string messageText)
        {
            if (messageText.Equals("/meteor", StringComparison.InvariantCultureIgnoreCase))
            {
                MatrixD worldMatrix;
                Vector3D position;

                if (MyAPIGateway.Session.Player.Controller.ControlledEntity.Entity.Parent == null)
                {
                    worldMatrix = MyAPIGateway.Session.Player.Controller.ControlledEntity.GetHeadMatrix(true, true, false); // dead center of player cross hairs.
                    position = worldMatrix.Translation + worldMatrix.Forward * 1.5f; // Spawn item 1.5m in front of player for safety.
                }
                else
                {
                    worldMatrix = MyAPIGateway.Session.Player.Controller.ControlledEntity.Entity.WorldMatrix;
                    position = worldMatrix.Translation + worldMatrix.Forward * 1.5f + worldMatrix.Up * 0.5f; // Spawn item 1.5m in front of player in cockpit for safety.
                }

                var meteorBuilder = new MyObjectBuilder_Meteor()
                {
                    Item = new MyObjectBuilder_InventoryItem()
                    {
                        Amount = 10000,
                        Content = new MyObjectBuilder_Ore() { SubtypeName = _defaultOreName }
                    },
                    PersistentFlags = MyPersistentEntityFlags2.InScene, // Very important
                    PositionAndOrientation = new MyPositionAndOrientation()
                    {
                        Position = position,
                        Forward = (Vector3)worldMatrix.Forward,
                        Up = (Vector3)worldMatrix.Up,
                    },
                    LinearVelocity = worldMatrix.Forward * 300,
                    Integrity = 100,
                };

                meteorBuilder.CreateAndSyncEntity();
                return true;
            }

            return false;
        }
        public static void Smite(IMyPlayer selectedPlayer)
        {
            var worldMatrix = selectedPlayer.Controller.ControlledEntity.GetHeadMatrix(true, true, true);
            var maxspeed = MyDefinitionManager.Static.EnvironmentDefinition.SmallShipMaxSpeed * 1.25f;

            var meteorBuilder = new MyObjectBuilder_Meteor
            {
                Item = new MyObjectBuilder_InventoryItem { Amount = 1, Content = new MyObjectBuilder_Ore { SubtypeName = CommandPlayerSmite.Instance._defaultOreName } },
                PersistentFlags = MyPersistentEntityFlags2.InScene, // Very important
                PositionAndOrientation = new MyPositionAndOrientation
                {
                    Position = (worldMatrix.Translation + worldMatrix.Up * -0.5f).ToSerializableVector3D(),
                    Forward = worldMatrix.Forward.ToSerializableVector3(),
                    Up = worldMatrix.Up.ToSerializableVector3(),
                },
                LinearVelocity = worldMatrix.Down * -maxspeed, // has to be faster than JetPack speed, otherwise it could be avoided.
                // Update 01.052 seemed to have flipped the direction. It's Up instead of Down???
                Integrity = 1
            };

            meteorBuilder.CreateAndSyncEntity();
        }
Esempio n. 3
0
		public Meteor( MyObjectBuilder_Meteor definition, Object backingObject )
			: base( definition, backingObject )
		{
			m_item = new InventoryItemEntity( definition.Item );
		}
        private void ThrowMeteor(IMyPlayer player, string oreName)
        {
            MatrixD worldMatrix;
            Vector3D position;

            if (player.Controller.ControlledEntity.Entity.Parent == null)
            {
                worldMatrix = player.Controller.ControlledEntity.GetHeadMatrix(true, true, false); // dead center of player cross hairs.
                position = worldMatrix.Translation + worldMatrix.Forward * 1.5f; // Spawn item 1.5m in front of player for safety.
            }
            else
            {
                worldMatrix = player.Controller.ControlledEntity.Entity.WorldMatrix;
                position = worldMatrix.Translation + worldMatrix.Forward * 1.5f + worldMatrix.Up * 0.5f; // Spawn item 1.5m in front of player in cockpit for safety.
            }

            var meteorBuilder = new MyObjectBuilder_Meteor()
            {
                Item = new MyObjectBuilder_InventoryItem()
                {
                    Amount = 10000,
                    Content = new MyObjectBuilder_Ore() { SubtypeName = oreName }
                },
                PersistentFlags = MyPersistentEntityFlags2.InScene, // Very important
                PositionAndOrientation = new MyPositionAndOrientation()
                {
                    Position = position,
                    Forward = (Vector3)worldMatrix.Forward,
                    Up = (Vector3)worldMatrix.Up,
                },
                LinearVelocity = worldMatrix.Forward * 500,
                Integrity = 100,
            };

            meteorBuilder.CreateAndSyncEntity();
        }