Exemplo n.º 1
0
        private void spawnMeteor(Vector3Wrapper spawnpos, Vector3Wrapper vel, Vector3Wrapper up, Vector3Wrapper forward)
        {
            if (SandboxGameAssemblyWrapper.IsDebugging)
            {
                LogManager.APILog.WriteLineAndConsole("Physics Meteroid - spawnMeteor(" + spawnpos.ToString() + ", " + vel.ToString() + ", " + up.ToString() + ", " + forward.ToString() + ")" );
            }
            MyObjectBuilder_FloatingObject tempobject;
            MyObjectBuilder_Ore tempore = new MyObjectBuilder_Ore();
            MyObjectBuilder_InventoryItem tempitem = new MyObjectBuilder_InventoryItem();
            tempore.SetDefaultProperties();
            FloatingObject physicsmeteor;
            m_ore_fctr = m_gen.NextDouble();

            tempitem = (MyObjectBuilder_InventoryItem)MyObjectBuilder_InventoryItem.CreateNewObject(m_InventoryItemType);
            tempitem.PhysicalContent = (MyObjectBuilder_PhysicalObject)MyObjectBuilder_PhysicalObject.CreateNewObject(m_OreType);
            tempitem.PhysicalContent.SubtypeName = getRandomOre();
            tempitem.AmountDecimal = Math.Round((decimal)(ore_amt * getOreFctr(tempitem.PhysicalContent.SubtypeName) * m_ore_fctr));
            if (tempitem.AmountDecimal < 1) tempitem.AmountDecimal = 1;
            tempitem.ItemId = 0;

            tempobject = (MyObjectBuilder_FloatingObject)MyObjectBuilder_FloatingObject.CreateNewObject(m_FloatingObjectType);
            tempobject.Item = tempitem;

            physicsmeteor = new FloatingObject(tempobject);
            physicsmeteor.Up = up;
            physicsmeteor.Forward = forward;
            physicsmeteor.Position = spawnpos;
            physicsmeteor.LinearVelocity = vel;
            physicsmeteor.MaxLinearVelocity = 104.7F * maxVelocityFctr;
            if (SandboxGameAssemblyWrapper.IsDebugging)
            {
                LogManager.APILog.WriteLineAndConsole("Meteor entityID: " + physicsmeteor.EntityId.ToString() + " Velocity: " + vel.ToString());
            }
            SectorObjectManager.Instance.AddEntity(physicsmeteor);
            //workaround for the velocity problem.
            Thread physicsthread = new Thread(() => velocityloop(physicsmeteor, vel));
            physicsthread.Start();
        }
Exemplo n.º 2
0
 private void spawnMeteor(Vector3Wrapper spawnpos, Vector3Wrapper vel)
 {
     spawnMeteor(spawnpos, vel, new Vector3Wrapper(0F,1F,0F), new Vector3Wrapper(0F,0F,-1F));
 }
Exemplo n.º 3
0
        public void velocityloop(FloatingObject obj, Vector3Wrapper vel)
        {
            Thread.Sleep(20);
            for (int count = 20; count > 0; count--)
            {
                if (obj.Mass > 0)
                {
                    obj.MaxLinearVelocity = 104.7F * maxVelocityFctr;
                    obj.LinearVelocity = vel;
                    if (SandboxGameAssemblyWrapper.IsDebugging)
                    {
                        LogManager.APILog.WriteLineAndConsole("Meteor entityID: " + obj.EntityId.ToString() + " Velocity: " + vel.ToString());
                    }
                    break;
                }
                Thread.Sleep(20);
            }

            return;
        }