Exemple #1
0
        void CreateCustomWorldStone()
        {
            List <BoundingSphere> safeAreas = new List <BoundingSphere>();

            foreach (MyEntity entity in MyEntities.GetEntities())
            {
                MyDummyPoint dummyPoint = entity as MyDummyPoint;

                if (dummyPoint != null && dummyPoint.DummyFlags.HasFlag(MinerWars.CommonLIB.AppCode.ObjectBuilders.SubObjects.MyDummyPointFlags.SAFE_AREA))
                {
                    safeAreas.Add(dummyPoint.WorldVolume);
                }
            }

            BoundingSphere playerSafeArea = new BoundingSphere(MySession.PlayerShip.GetPosition(), 150); //smallship + mothership

            safeAreas.Add(playerSafeArea);

            //MyEntities.CloseAll(false);
            var generator     = new MySectorGenerator((int)DateTime.Now.Ticks, safeAreas);
            var sectorObjects = generator.GenerateObjectBuilders(MyGuiScreenGamePlay.Static.GetSectorIdentifier().Position, m_sectorObjectCounts, false);

            MyGuiScreenGamePlay.CreateFromSectorObjectBuilder(sectorObjects);

            MyEntities.UpdateAfterSimulation(); //Updates AABBs of objects
            MinerWars.AppCode.Game.Render.MyRender.RebuildCullingStructure();
        }
Exemple #2
0
        private static void UpdateStartDummy(MyDummyPointFlags flags, Matrix position)
        {
            MyDummyPoint playerStartDummy = null;

            foreach (var entity in MyEntities.GetEntities())
            {
                MyDummyPoint dummy = entity as MyDummyPoint;
                if (dummy != null && (dummy.DummyFlags & flags) > 0)
                {
                    playerStartDummy = dummy;
                    break;
                }
            }

            if (playerStartDummy == null)
            {
                MyMwcObjectBuilder_DummyPoint dummyPointObjectBuilder =
                    MyMwcObjectBuilder_Base.CreateNewObject(MyMwcObjectBuilderTypeEnum.DummyPoint, null) as
                    MyMwcObjectBuilder_DummyPoint;
                playerStartDummy =
                    MyEntities.CreateFromObjectBuilderAndAdd(null, dummyPointObjectBuilder, Matrix.Identity) as MyDummyPoint;
                playerStartDummy.DummyFlags |= flags;
            }

            playerStartDummy.SetWorldMatrix(position);
        }
        void detector_OnEntityEnter(MyEntityDetector sender, MyEntity entity, int meetCriterias)
        {
            MyDummyPoint    dummy     = (MyDummyPoint)sender.Parent;
            uint            scannerId = (uint)dummy.Tag;
            MyPrefabScanner scanner   = (MyPrefabScanner)MyScriptWrapper.GetEntity(scannerId);

            scanner.Enabled = false;
        }
 private void Reset()
 {
     foreach (uint item in Puzzle)
     {
         var          puzzleDetector = MyScriptWrapper.GetDetector(MyScriptWrapper.GetEntity(item));
         MyDummyPoint dummyPoint     = (MyDummyPoint)puzzleDetector.Parent;
         dummyPoint.Color = Color.Yellow.ToVector4();
     }
 }
        public void UpdateDummyFlags(MyDummyPoint dummyPoint)
        {
            Debug.Assert(dummyPoint.EntityId.HasValue);

            var msg = new MyEventDummyFlags();

            msg.Flags    = dummyPoint.DummyFlags;
            msg.EntityId = dummyPoint.EntityId.Value.NumericValue;
        }
Exemple #6
0
 private static void SetDummyVisibleStatus(MyDummyPoint platform, bool visible)
 {
     if (visible)
     {
         MyScriptWrapper.UnhideEntity(platform);
     }
     else
     {
         MyScriptWrapper.HideEntity(platform);
     }
 }
        void puzzleDetector_OnEntityEnter(MyEntityDetector sender, MyEntity entity, int meetCriterias)
        {
            MyDummyPoint dummyPoint = (MyDummyPoint)sender.Parent;

            if (dummyPoint.Color == Color.Green.ToVector4())
            {
                Reset();
            }
            else
            {
                dummyPoint.Color = Color.Green.ToVector4();
            }
        }
 private bool CheckWin()
 {
     foreach (uint item in Puzzle)
     {
         var          puzzleDetector = MyScriptWrapper.GetDetector(MyScriptWrapper.GetEntity(item));
         MyDummyPoint dummyPoint     = (MyDummyPoint)puzzleDetector.Parent;
         if (dummyPoint.Color != Color.Green.ToVector4())
         {
             Reset();
             return(false);
         }
     }
     return(true);
 }
Exemple #9
0
        public static Matrix FindMothershipPosition()
        {
            foreach (MyEntity entity in MyEntities.GetEntities())
            {
                MyDummyPoint dummyPoint = entity as MyDummyPoint;
                if (dummyPoint != null)
                {
                    if ((dummyPoint.DummyFlags & MyDummyPointFlags.MOTHERSHIP_START) > 0)
                    {
                        return(dummyPoint.WorldMatrix);
                    }
                }
            }

            return(Matrix.CreateWorld(MySession.PlayerShip.GetPosition() + new Vector3(100, 100, 0), Vector3.Forward, Vector3.Up));
        }
        void detector_OnEntityLeave(MyEntityDetector sender, MyEntity entity)
        {
            //MySpawnPoint spawnPoint = (MySpawnPoint)MyScriptWrapper.GetEntity((uint)EntityID.PatrolSpawnPoint);

            MyDummyPoint dummy = (MyDummyPoint)sender.Parent;


            if (MyFactions.GetFactionsRelation(dummy, entity) == MyFactionRelationEnum.Friend)
            {
            }


            uint            scannerId = (uint)dummy.Tag;
            MyPrefabScanner scanner   = (MyPrefabScanner)MyScriptWrapper.GetEntity(scannerId);

            scanner.Enabled = true;
        }
        private void OnAttachClick(MyGuiControlBase button)
        {
            if (MyEditorVoxelHand.DetachedVoxelHand == null)
            {
                foreach (MyEntity e in MyEntities.GetEntities())
                {
                    if (e is MyDummyPoint && ((int)(((MyDummyPoint)e).DummyFlags & CommonLIB.AppCode.ObjectBuilders.SubObjects.MyDummyPointFlags.VOXEL_HAND)) > 0)
                    {
                        e.WorldMatrix = MyEditorVoxelHand.UpdateShapePosition();
                        MyEditorVoxelHand.DetachedVoxelHand = (MyDummyPoint)e;
                    }
                }

                if (MyEditorVoxelHand.DetachedVoxelHand == null)
                {
                    var          ob        = MinerWars.CommonLIB.AppCode.ObjectBuilders.MyMwcObjectBuilder_Base.CreateNewObject(MinerWars.CommonLIB.AppCode.ObjectBuilders.MyMwcObjectBuilderTypeEnum.DummyPoint, null) as MinerWars.CommonLIB.AppCode.ObjectBuilders.SubObjects.MyMwcObjectBuilder_DummyPoint;
                    MyDummyPoint voxelHand = new MyDummyPoint();
                    voxelHand.Init(null, ob, Matrix.Identity);
                    voxelHand.DummyFlags |= CommonLIB.AppCode.ObjectBuilders.SubObjects.MyDummyPointFlags.VOXEL_HAND;
                    voxelHand.Size        = new Vector3(20, 20, 20);
                    voxelHand.Save        = false;
                    voxelHand.WorldMatrix = MyEditorVoxelHand.UpdateShapePosition();
                    MyEntities.Add(voxelHand);
                    MyEditorVoxelHand.DetachedVoxelHand = voxelHand;
                }


                MyEditorVoxelHand.DetachedVoxelHand.Enabled = true;
                MyEditorGizmo.SelectedEntities.Clear();
                MyEditorGizmo.SelectedEntities.Add(MyEditorVoxelHand.DetachedVoxelHand);

                m_detachLabel.Text = MyTextsWrapperEnum.AttachVoxelHand;
            }
            else
            {
                if (MyEditorVoxelHand.DetachedVoxelHand != null)
                {
                    MyEditorVoxelHand.DetachedVoxelHand.MarkForClose();
                }
                MyEditorVoxelHand.DetachedVoxelHand = null;
                MyEditorGizmo.SelectedEntities.Clear();
                m_detachLabel.Text = MyTextsWrapperEnum.DetachVoxelHand;
            }
        }
        public override void Load()
        {
            if (!IsMainSector)
            {
                return;
            }

            base.Load();

            // Change player faction to Rainiers and set relations between them
            MyScriptWrapper.SetPlayerFaction(MyMwcObjectBuilder_FactionEnum.Rainiers);
            MyScriptWrapper.SetFactionRelation(MyMwcObjectBuilder_FactionEnum.Rainiers, MyMwcObjectBuilder_FactionEnum.WhiteWolves, MyFactions.RELATION_WORST);
            MyScriptWrapper.FixBotNames();

            // Set musicmood right from script start
            MyScriptWrapper.ApplyTransition(MyMusicTransitionEnum.Horror);

            //TODO: this should be set in editor
            foreach (uint id in m_particlesExplosion1)
            {
                MyDummyPoint dummy = MyScriptWrapper.TryGetEntity(id) as MyDummyPoint;
                if (dummy != null)
                {
                    dummy.DummyFlags |= MyDummyPointFlags.SURIVE_PREFAB_DESTRUCTION;
                }
            }
            foreach (uint id in m_particlesExplosion2)
            {
                MyDummyPoint dummy = MyScriptWrapper.TryGetEntity(id) as MyDummyPoint;
                if (dummy != null)
                {
                    dummy.DummyFlags |= MyDummyPointFlags.SURIVE_PREFAB_DESTRUCTION;
                }
            }
            foreach (uint id in m_particlesExplosion3)
            {
                MyDummyPoint dummy = MyScriptWrapper.TryGetEntity(id) as MyDummyPoint;
                if (dummy != null)
                {
                    dummy.DummyFlags |= MyDummyPointFlags.SURIVE_PREFAB_DESTRUCTION;
                }
            }
        }
        public override void Load()
        {
            base.Load();
            var entities = MyEntities.GetEntities();

            var detectorsIds = new[] { EntityID.Detector0, EntityID.Detector1, EntityID.Detector2 };
            var scannerIds   = new[] { EntityID.Scanner0, EntityID.Scanner1, EntityID.Scanner2 };

            for (int i = 0; i < detectorsIds.Length; i++)
            {
                MyDummyPoint    dummy   = (MyDummyPoint)MyScriptWrapper.GetEntity((uint)detectorsIds[i]);
                MyPrefabScanner scanner = (MyPrefabScanner)MyScriptWrapper.GetEntity((uint)scannerIds[i]);
                dummy.Tag = scanner.EntityId.Value.NumericValue;

                var detector = dummy.GetDetector();
                detector.OnEntityEnter += new OnEntityEnter(detector_OnEntityEnter);
                detector.OnEntityLeave += new OnEntityLeave(detector_OnEntityLeave);
                detector.On();
            }
        }
Exemple #14
0
        private static void UpdatePlayerStartDummy(MyMwcObjectBuilder_Checkpoint checkpoint)
        {
            var dummyBuilder = checkpoint.SectorObjectBuilder.SectorObjects.OfType <MyMwcObjectBuilder_DummyPoint>().FirstOrDefault(s => (s.DummyFlags & MyDummyPointFlags.PLAYER_START) > 0);

            if (dummyBuilder == null)
            {
                dummyBuilder            = MyMwcObjectBuilder_Base.CreateNewObject(MyMwcObjectBuilderTypeEnum.DummyPoint, null) as MyMwcObjectBuilder_DummyPoint;
                dummyBuilder.DummyFlags = MyDummyPointFlags.PLAYER_START;
                checkpoint.SectorObjectBuilder.SectorObjects.Add(dummyBuilder);

                var dummyEntity = new MyDummyPoint();
                dummyEntity.Init(String.Empty, dummyBuilder, MySession.PlayerShip.WorldMatrix);
                MyEntities.Add(dummyEntity);
            }

            MyGuiScreenGamePlay.Static.ClampPlayerToBorderSafeArea();

            dummyBuilder.PositionAndOrientation.Position = MySession.PlayerShip.WorldMatrix.Translation;
            dummyBuilder.PositionAndOrientation.Forward  = MySession.PlayerShip.WorldMatrix.Forward;
            dummyBuilder.PositionAndOrientation.Up       = MySession.PlayerShip.WorldMatrix.Up;
        }
Exemple #15
0
        void CreateGeneratedWorld()
        {
            //  MyEntities.CloseAll(false);
            List <MyMwcObjectBuilder_Base> objectBuilders = new List <MyMwcObjectBuilder_Base>();

            List <BoundingSphere> safeAreas = new List <BoundingSphere>();

            foreach (MyEntity existingEntity in MyEntities.GetEntities())
            {
                MyDummyPoint dummy = existingEntity as MyDummyPoint;
                if (dummy != null && dummy.DummyFlags.HasFlag(MinerWars.CommonLIB.AppCode.ObjectBuilders.SubObjects.MyDummyPointFlags.SAFE_AREA))
                {
                    safeAreas.Add(existingEntity.WorldVolume);
                }
            }

            MyGuiScreenGamePlay.Static.GenerateSector(MyGuiScreenGamePlay.Static.GetSectorIdentifier().Position, objectBuilders, safeAreas, false);
            MyGuiScreenGamePlay.CreateFromObjectBuilders(objectBuilders);

            MyEntities.UpdateAfterSimulation(); //Updates AABBs of objects
            MinerWars.AppCode.Game.Render.MyRender.RebuildCullingStructure();
        }
 public MyExplosionInfo(float playerDamage, float damage, float empDamage, BoundingSphere explosionSphere, MyExplosionTypeEnum type, bool playSound, MyDummyPoint customEffect = null, bool checkIntersection = true)
 {
     PlayerDamage            = playerDamage;
     Damage                  = damage;
     EmpDamage               = empDamage;
     ExplosionSphere         = explosionSphere;
     ExplosionForceDirection = MyExplosionForceDirection.EXPLOSION;
     StrengthImpulse         = StrengthAngularImpulse = 0.0f;
     ExcludedEntity          = OwnerEntity = HitEntity = null;
     CascadeLevel            = 0;
     ExplosionFlags          = MyExplosionFlags.AFFECT_VOXELS | MyExplosionFlags.APPLY_FORCE_AND_DAMAGE | MyExplosionFlags.CREATE_DEBRIS | MyExplosionFlags.CREATE_DECALS | MyExplosionFlags.CREATE_PARTICLE_EFFECT;
     ExplosionType           = type;
     LifespanMiliseconds     = MyExplosionsConstants.EXPLOSION_LIFESPAN;
     GroupMask               = MyGroupMask.Empty;
     ParticleScale           = 1.0f;
     VoxelCutoutScale        = 1.0f;
     Direction               = null;
     VoxelExplosionCenter    = explosionSphere.Center;
     PlaySound               = playSound;
     CustomEffect            = customEffect;
     CheckIntersections      = checkIntersection;
 }
Exemple #17
0
 protected static void HideDummy(MyDummyPoint platform)
 {
     SetDummyVisibleStatus(platform, false);
 }
Exemple #18
0
 public MyGuiScreenEditorDummyPoint(MyDummyPoint dummyPoint)
     : base(dummyPoint, new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null, MyTextsWrapperEnum.DummyPoint)
 {
     Init();
 }
Exemple #19
0
 protected static void ShowDummy(MyDummyPoint platform)
 {
     SetDummyVisibleStatus(platform, true);
 }