示例#1
0
文件: Server.cs 项目: senlace/shinkai
        private void Process(Client client, ClientCyclopsState msg)
        {
            SavedVehicle vehicle;

            if (state.history.vehicles.TryGetValue(msg.vehicleGuid, out vehicle))
            {
                vehicle.cyclopsState = msg;
                SendToAll(client.peer, msg);
            }
        }
示例#2
0
文件: Logic.cs 项目: senlace/shinkai
        public static void SendCyclopsState(SubRoot cyclops)
        {
            if (cyclops == null || Multiplayer.main.blocked)
            {
                return;
            }

            var res = new ClientCyclopsState();

            res.vehicleGuid = GuidHelper.Get(cyclops.gameObject);

            var shield = cyclops.GetComponentInChildren <CyclopsShieldButton>();

            if (shield != null)
            {
                res.shield = (bool)shield.ReflectionGet("active");
            }

            var engineState = cyclops.GetComponentInChildren <CyclopsEngineChangeState>();

            if (engineState != null)
            {
                res.engineOn       = engineState.motorMode.engineOn;
                res.engineStarting = (bool)engineState.ReflectionGet("startEngine");
                res.motorMode      = engineState.motorMode.cyclopsMotorMode;
            }

            var lighting = cyclops.GetComponentInChildren <CyclopsLightingPanel>();

            if (lighting != null)
            {
                res.floodLights    = lighting.floodlightsOn;
                res.internalLights = lighting.lightingOn;
            }

            var silentRunning = cyclops.GetComponentInChildren <CyclopsSilentRunningAbilityButton>();

            if (silentRunning != null)
            {
                res.silentRunning = (bool)silentRunning.ReflectionGet("active");
            }

            Multiplayer.main.Send(res);
        }
示例#3
0
        private void Process(ClientCyclopsState msg)
        {
            var cyclops = GuidHelper.Find(msg.vehicleGuid);

            if (cyclops == null)
            {
                return;
            }

            using (new MessageBlocker()) {
                var shield = cyclops.GetComponentInChildren <CyclopsShieldButton>();
                if (shield != null)
                {
                    bool active = (bool)shield.ReflectionGet("active");
                    if (active != msg.shield)
                    {
                        shield.OnClick();
                    }
                }

                var engineState = cyclops.GetComponentInChildren <CyclopsEngineChangeState>();
                if (engineState != null)
                {
                    if (msg.engineOn == engineState.motorMode.engineOn)
                    {
                        if (msg.engineStarting != (bool)engineState.ReflectionGet("startEngine"))
                        {
                            if (Player.main.currentSub != engineState.subRoot)
                            {
                                engineState.ReflectionSet("startEngine", !msg.engineOn);
                                engineState.ReflectionSet("invalidButton", true);
                                engineState.Invoke("ResetInvalidButton", 2.5f);
                                engineState.subRoot.BroadcastMessage("InvokeChangeEngineState", !msg.engineOn, SendMessageOptions.RequireReceiver);
                            }
                            else
                            {
                                engineState.ReflectionSet("invalidButton", false);
                                engineState.OnClick();
                            }
                        }
                    }
                    else
                    {
                        engineState.motorMode.ReflectionSet("engineOnOldState", msg.engineOn);
                        engineState.motorMode.RestoreEngineState();
                    }
                }

                var lighting = cyclops.GetComponentInChildren <CyclopsLightingPanel>();
                if (lighting != null)
                {
                    if (msg.floodLights != lighting.floodlightsOn)
                    {
                        lighting.ToggleFloodlights();
                    }

                    if (msg.internalLights != lighting.lightingOn)
                    {
                        lighting.ToggleInternalLighting();
                    }
                }

                var silentRunning = cyclops.GetComponentInChildren <CyclopsSilentRunningAbilityButton>();
                if (silentRunning != null)
                {
                    bool active = (bool)silentRunning.ReflectionGet("active");
                    if (msg.silentRunning != active)
                    {
                        if (msg.silentRunning)
                        {
                            silentRunning.ReflectionCall("TurnOnSilentRunning");
                        }
                        else
                        {
                            silentRunning.ReflectionCall("TurnOffSilentRunning");
                        }
                    }
                }

                var motorMode = cyclops.GetComponentInChildren <CyclopsMotorMode>();
                if (motorMode != null)
                {
                    if (msg.motorMode != motorMode.cyclopsMotorMode)
                    {
                        motorMode.BroadcastMessage("SetCyclopsMotorMode", msg.motorMode, SendMessageOptions.RequireReceiver);
                    }
                }
            }
        }