コード例 #1
0
        /// <summary>
        /// Callback called when world is loaded.
        /// </summary>
        public void OnLoad()
        {
            // Cache world time management fsm.
            GameObject sunGameObject = GameObject.Find("SUN");

            Client.Assert(sunGameObject != null, "SUN game object is missing!");

            // Yep it's called "Color" :>
            worldTimeFsm = Utils.GetPlaymakerScriptByName(sunGameObject, "Color");
            Client.Assert(worldTimeFsm != null, "Now world time FSM found :(");

            // Register refresh world time event.
            if (!worldTimeFsm.Fsm.HasEvent(REFRESH_WORLD_TIME_EVENT))
            {
                FsmEvent mpRefreshWorldTimeEvent = worldTimeFsm.Fsm.GetEvent(REFRESH_WORLD_TIME_EVENT);
                PlayMakerUtils.AddNewGlobalTransition(worldTimeFsm, mpRefreshWorldTimeEvent, "State 1");
            }

            // Make sure world time is up-to-date with cache.
            WorldTime = worldTimeCached;

            gameAnimDatabase.Rebuild();
            gamePickupableDatabase.Rebuild();

            doorsManager.OnWorldLoad();
            beerCaseManager.OnWorldLoad();
            lightSwitchManager.OnWorldLoad();
            LoadMailbox();
            LoadVehicles();

            if (GameCallbacks.onWorldLoad != null)
            {
                GameCallbacks.onWorldLoad();
            }
        }
コード例 #2
0
ファイル: GameWorld.cs プロジェクト: RootKiller/MSCMP-OLD-1
		/// <summary>
		/// Callback called when world is loaded.
		/// </summary>
		public void OnLoad() {
			// Register all game objects.

			GameObject[] gos = Resources.FindObjectsOfTypeAll<GameObject>();

			foreach (GameObject go in gos) {
				if (!worldHashGenerated) {
					Transform transform = go.transform;
					while (transform != null) {
						worldHash ^= Utils.StringJenkinsHash(transform.name);
						transform = transform.parent;
					}
				}

				HandleNewObject(go);
			}

			Logger.Log("World hash: " + worldHash);
			worldHashGenerated = true;

			// Check mandatory objects.

			Client.Assert(worldTimeFsm != null, "No world time FSM found :(");
			Client.Assert(lastnameFSM != null, "Mailbox FSM couldn't be found!");
			Client.Assert(lastnameTextMesh != null, "Mailbox TextMesh couldn't be found!");

			// Notify different parts of the mod about the world load.

			if (GameCallbacks.onWorldLoad != null) {
				GameCallbacks.onWorldLoad();
			}
		}
コード例 #3
0
ファイル: GameWorld.cs プロジェクト: kuppa213/MSCMP
        /// <summary>
        /// Callback called when world gets unloaded.
        /// </summary>
        public void OnUnload()
        {
            if (GameCallbacks.onWorldUnload != null)
            {
                GameCallbacks.onWorldUnload();
            }

            vehicles.Clear();
            player = null;
        }
コード例 #4
0
ファイル: GameWorld.cs プロジェクト: kuppa213/MSCMP
        /// <summary>
        /// Callback called when world is loaded.
        /// </summary>
        public void OnLoad()
        {
            gameAnimDatabase.Rebuild();
            gamePickupableDatabase.Rebuild();

            doorsManager.OnWorldLoad();
            LoadVehicles();

            if (GameCallbacks.onWorldLoad != null)
            {
                GameCallbacks.onWorldLoad();
            }
        }
コード例 #5
0
ファイル: GameWorld.cs プロジェクト: RootKiller/MSCMP-OLD-1
		/// <summary>
		/// Update game world state.
		/// </summary>
		public void Update() {
			if (player == null) {
				var playerGo = GameObject.Find("PLAYER");

				if (playerGo != null) {
					player = new GamePlayer(playerGo);

					if (GameCallbacks.onLocalPlayerCreated != null) {
						GameCallbacks.onLocalPlayerCreated();
					}
				}
			}
		}
コード例 #6
0
ファイル: GameWorld.cs プロジェクト: RootKiller/MSCMP-OLD-1
		/// <summary>
		/// Callback called when world gets unloaded.
		/// </summary>
		public void OnUnload() {
			// Iterate backwards so pickupable users will be notified before the database.

			for (int i = gameObjectUsers.Count; i > 0; --i) {
				gameObjectUsers[i - 1].DestroyObjects();
			}

			if (GameCallbacks.onWorldUnload != null) {
				GameCallbacks.onWorldUnload();
			}

			player = null;
		}