示例#1
0
        /// <summary>
        /// Return the first active SFXState in the given SimSet/SimGroup.
        /// </summary>
        /// <param name="group"></param>
        public static SFXState sfxGetActiveStateInGroup(SimGroup group)
        {
            for (uint i = 0; i < group.getCount(); i++)
            {
                SimObject obj = group.getObject(i);
                if (!obj.isMemberOfClass("SFXState"))
                {
                    continue;
                }

                SFXState state = obj.As <SFXState>();
                if (state.isActive())
                {
                    return(state);
                }
            }

            return(null);
        }
示例#2
0
        public SceneObject PickCameraSpawnPoint(string spawnGroups)
        {
            SimObject spawnPoint = spawnGroups.Split(' ')
                                   .ToList()
                                   .Select((group) => Sim.FindObjectByName <SimSet>(group)?.GetRandom())
                                   .ToList()
                                   .Find((x) => x != null && Global.IsObject(x.GetId().ToString()));

            if (spawnPoint != null)
            {
                return(spawnPoint.As <SceneObject>());
            }

            // Didn't find a spawn point by looking for the groups
            // so let's return the "default" SpawnSphere
            // First create it if it doesn't already exist
            SpawnSphere spawn;

            if (!Global.IsObject("DefaultCameraSpawnSphere"))
            {
                spawn = new SpawnSphere("DefaultCameraSpawnSphere")
                {
                    DataBlock      = Sim.FindObjectByName <GameBaseData>("SpawnSphereMarker"),
                    SpawnClass     = Global.GetConsoleString("Game::DefaultCameraClass"),
                    SpawnDatablock = Global.GetConsoleString("Game::DefaultCameraDataBlock"),
                };
                spawn.RegisterObject();

                // Add it to the MissionCleanup group so that it
                // doesn't get saved to the Mission (and gets cleaned
                // up of course)
                Core.SimObjects.Collections.MissionCleanup.Add(spawn);
            }
            else
            {
                spawn = Sim.FindObjectByName <SpawnSphere>("DefaultCameraSpawnSphere");
            }

            return(spawn);
        }
        public override void onActivate()
        {
            base.onActivate();

            SimGroup group = ParentGroup.As <SimGroup>();

            for (uint i = 0; i < group.getCount(); i++)
            {
                SimObject obj = group.getObject(i);

                if (obj.getId() == getId() || !obj.isMemberOfClass("SFXState"))
                {
                    continue;
                }

                SFXState state = obj.As <SFXState>();
                if (state.isActive())
                {
                    state.deactivate();
                }
            }
        }