예제 #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
		/// <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
		/// <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
		/// <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;
		}