예제 #1
0
        protected override void Init()
        {
            base.Init();

            _controller = GetComponent <LocoControllerShunter>();
            _action     = new LocoShunterActionPacket()
            {
                Id = Id
            };
        }
예제 #2
0
        private bool PopulateActionPacket(LocoShunterActionPacket action)
        {
            var flags = ShunterStateFlags.None;

            flags |= _controller.GetEngineRunning() ? ShunterStateFlags.EngineOn : 0;
            flags |= _controller.GetSandersOn() ? ShunterStateFlags.SandOn : 0;
            flags |= _controller.backlight ? ShunterStateFlags.LightOn : 0;
            flags |= _controller.fan ? ShunterStateFlags.FanOn : 0;
            flags |= _controller.headlights.activeSelf ? ShunterStateFlags.HeadlightOn : 0;

            return(SetStateValue(ref action.Flags, flags) |
                   SetStateValue(ref action.TargetThrottle, _controller.targetThrottle) |
                   SetStateValue(ref action.TargetBrake, _controller.targetBrake) |
                   SetStateValue(ref action.TargetIndependentBrake, _controller.targetIndependentBrake) |
                   SetStateValue(ref action.Reverser, _controller.reverser));
        }
예제 #3
0
        public bool Receive(LocoShunterActionPacket packet, ClientId client)
        {
            if (packet.Id != Id)
            {
                return(false);
            }

            Logging <TrainCarSync> .LogDebug($"LocoShunterActionPacket: {packet.Flags} / {packet.TargetThrottle} / {packet.TargetBrake} / {packet.TargetIndependentBrake}");

            _controller.SetThrottle(packet.TargetThrottle);
            _controller.SetBrake(packet.TargetBrake);
            _controller.SetIndependentBrake(packet.TargetIndependentBrake);
            _controller.SetReverser(packet.Reverser);
            _controller.SetEngineRunning((packet.Flags & ShunterStateFlags.EngineOn) != 0);
            _controller.SetSandersOn((packet.Flags & ShunterStateFlags.SandOn) != 0);
            _controller.backlight = (packet.Flags & ShunterStateFlags.LightOn) != 0;
            _controller.fan       = (packet.Flags & ShunterStateFlags.FanOn) != 0;
            _controller.headlights.SetActive((packet.Flags & ShunterStateFlags.HeadlightOn) != 0);

            return(true);
        }