예제 #1
0
파일: PhoneManager.cs 프로젝트: Najsr/MSCMP
        /// <summary>
        /// Hook phone related events.
        /// </summary>
        void HookEvents()
        {
            gameObject.SetActive(true);

            ringFSM = Utils.GetPlaymakerScriptByName(gameObject, "Ring");
            EventHook.Add(ringFSM, "State 4", new Func <bool>(() => {
                if (Network.NetManager.Instance.IsHost)
                {
                    WritePhoneCall();
                }
                return(false);
            }));

            EventHook.Add(ringFSM, "Disable phone", new Func <bool>(() => {
                return(false);
            }));

            EventHook.AddWithSync(ringFSM, "Thunder calls");

            gameObject.SetActive(false);
        }
예제 #2
0
파일: EventHook.cs 프로젝트: Najsr/MSCMP
        /// <summary>
        /// Sync all events within a given FSM.
        /// </summary>
        /// <param name="fsm">FSM to sync Events of.</param>
        /// <param name="action">Optional action, default will only run events for the sync owner, or host is no one owns the object.</param>
        public static void SyncAllEvents(PlayMakerFSM fsm, Func <bool> action = null)
        {
            if (fsm == null)
            {
                Client.Assert(true, "EventHook SyncAllEvents: Failed to hook event. (FSM is null)");
                return;
            }
            FsmState[] states = fsm.FsmStates;

            foreach (FsmState state in states)
            {
                EventHook.AddWithSync(fsm, state.Name, new Func <bool>(() => {
                    if (action != null)
                    {
                        return(action());
                    }
                    else
                    {
                        return(false);
                    }
                }));
            }
        }
예제 #3
0
        /// <summary>
        /// Collect given objects.
        /// </summary>
        /// <param name="gameObject">The game object to collect.</param>
        public void CollectGameObject(GameObject gameObject)
        {
            if (gameObject.name == "SUN" && worldTimeFsm == null)
            {
                // Yep it's called "Color" :>
                worldTimeFsm = Utils.GetPlaymakerScriptByName(gameObject, "Color");
                if (worldTimeFsm == null)
                {
                    return;
                }

                // 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;
            }
            else if (Utils.IsGameObjectHierarchyMatching(gameObject, "mailbox_bottom_player/Name"))
            {
                SetupMailbox(gameObject);
            }
            else if (gameObject.name == "TRAFFIC")
            {
                trafficManager.Setup(gameObject);
            }
            else if (gameObject.name == "STORE")
            {
                shopManager.Setup(gameObject);
            }
            else if (gameObject.name == "BOAT")
            {
                ObjectSyncComponent osc = gameObject.transform.FindChild("GFX/Colliders/Collider").gameObject.AddComponent <ObjectSyncComponent>();
                osc.Setup(ObjectSyncManager.ObjectTypes.Boat, ObjectSyncManager.AUTOMATIC_ID);
            }

            // Garage doors.
            else if (gameObject.name == "GarageDoors")
            {
                ObjectSyncComponent oscLeft = gameObject.transform.FindChild("DoorLeft/Coll").gameObject.AddComponent <ObjectSyncComponent>();
                oscLeft.Setup(ObjectSyncManager.ObjectTypes.GarageDoor, ObjectSyncManager.AUTOMATIC_ID);
                ObjectSyncComponent oscRight = gameObject.transform.FindChild("DoorRight/Coll").gameObject.AddComponent <ObjectSyncComponent>();
                oscRight.Setup(ObjectSyncManager.ObjectTypes.GarageDoor, ObjectSyncManager.AUTOMATIC_ID);
            }
            // Old car shed doors.
            else if (gameObject.name == "Doors" && gameObject.transform.parent.name == "Shed")
            {
                PlayMakerFSM doorLeft = gameObject.transform.FindChild("DoorLeft/Mesh").gameObject.GetComponent <PlayMakerFSM>();
                EventHook.AddWithSync(doorLeft, "Open door");
                EventHook.AddWithSync(doorLeft, "Close door");
                PlayMakerFSM doorRight = gameObject.transform.FindChild("DoorRight/Mesh").gameObject.GetComponent <PlayMakerFSM>();
                EventHook.AddWithSync(doorRight, "Open door");
                EventHook.AddWithSync(doorRight, "Close door");
            }

            // Weather system.
            else if (gameObject.name == "Clouds" && gameObject.transform.parent.name == "CloudSystem")
            {
                ObjectSyncComponent osc = gameObject.AddComponent <ObjectSyncComponent>();
                osc.Setup(ObjectSyncManager.ObjectTypes.Weather, ObjectSyncManager.AUTOMATIC_ID);
            }

            // Sewage well jobs.
            else if (gameObject.name.StartsWith("HouseShit"))
            {
                ObjectSyncComponent osc = gameObject.AddComponent <ObjectSyncComponent>();
                osc.Setup(ObjectSyncManager.ObjectTypes.SewageWell, ObjectSyncManager.AUTOMATIC_ID);
            }

            // Phone.
            else if (gameObject.name == "Ring")
            {
                phoneManager.Setup(gameObject);
            }
            // Map.
            else if (gameObject.name == "MAP" && gameObject.transform.FindChild("Darts"))
            {
                mapManager.Setup(gameObject);
            }
        }
예제 #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public EventHook()
 {
     Instance = this;
 }