Beispiel #1
0
        public void ServerRead(ClientNetObject type, NetBuffer msg, Client c)
        {
            bool  autoTemp     = msg.ReadBoolean();
            float shutDownTemp = msg.ReadRangedSingle(0.0f, 10000.0f, 15);
            float coolingRate  = msg.ReadRangedSingle(0.0f, 100.0f, 8);
            float fissionRate  = msg.ReadRangedSingle(0.0f, 100.0f, 8);

            if (!item.CanClientAccess(c))
            {
                return;
            }

            if (!autoTemp && AutoTemp)
            {
                BlameOnBroken = c;
            }
            if (shutDownTemp > ShutDownTemp)
            {
                BlameOnBroken = c;
            }
            if (fissionRate > FissionRate)
            {
                BlameOnBroken = c;
            }

            if (GameMain.NilMod.EnableGriefWatcher)
            {
                if (!autoTemp && AutoTemp && NilMod.NilModGriefWatcher.ReactorAutoTempOff &&
                    item.Submarine != null && item.Submarine.TeamID == c.Character.TeamID)
                {
                    NilMod.NilModGriefWatcher.SendWarning(c.Character.LogName
                                                          + " has turned off reactor AutoTemp", c);
                }

                if (shutDownTemp > ShutDownTemp &&
                    (shutDownTemp > FireTemp || shutDownTemp > MeltDownTemp) &&
                    NilMod.NilModGriefWatcher.ReactorShutDownTemp &&
                    item.Submarine != null && item.Submarine.TeamID == c.Character.TeamID)
                {
                    if (!CoroutineManager.IsCoroutineRunning("GWwarnshutdowntemp_" + c.Name))
                    {
                        CoroutineManager.StartCoroutine(WarnShutDownTemp(c, shutDownTemp), "GWwarnshutdowntemp_" + c.Name);
                    }
                }

                if (fissionRate > FissionRate && NilMod.NilModGriefWatcher.ReactorFissionBeyondAuto &&
                    item.Submarine != null && item.Submarine.TeamID == c.Character.TeamID)
                {
                    if (!CoroutineManager.IsCoroutineRunning("GWwarnfission_" + c.Name))
                    {
                        CoroutineManager.StartCoroutine(WarnFissionRate(c, fissionRate), "GWwarnfission_" + c.Name);
                    }
                }
            }

            AutoTemp     = autoTemp;
            ShutDownTemp = shutDownTemp;

            CoolingRate = coolingRate;
            FissionRate = fissionRate;

            lastUser = c.Character;
            if (nextServerLogWriteTime == null)
            {
                nextServerLogWriteTime = Math.Max(lastServerLogWriteTime + 1.0f, (float)Timing.TotalTime);
            }

            //need to create a server event to notify all clients of the changed state
            unsentChanges = true;
        }
        private void UpdateReturning(float deltaTime)
        {
            //if (shuttleReturnTimer == maxTransportTime &&
            //    networkMember.Character != null &&
            //    networkMember.Character.Submarine == respawnShuttle)
            //{
            //    networkMember.AddChatMessage("The shuttle will automatically return back to the outpost. Please leave the shuttle immediately.", ChatMessageType.Server);
            //}

            shuttleReturnTimer -= deltaTime;

            updateReturnTimer += deltaTime;

            if (updateReturnTimer > 1.0f)
            {
                updateReturnTimer = 0.0f;

                respawnShuttle.PhysicsBody.FarseerBody.IgnoreCollisionWith(Level.Loaded.TopBarrier);

                if (shuttleSteering != null)
                {
                    shuttleSteering.SetDestinationLevelStart();
                }

                foreach (Door door in shuttleDoors)
                {
                    if (door.IsOpen)
                    {
                        door.SetState(false, false, true);
                    }
                }

                var shuttleGaps = Gap.GapList.FindAll(g => g.Submarine == respawnShuttle && g.ConnectedWall != null);
                shuttleGaps.ForEach(g => g.Remove());

                var dockingPorts = Item.ItemList.FindAll(i => i.Submarine == respawnShuttle && i.GetComponent <DockingPort>() != null);
                dockingPorts.ForEach(d => d.GetComponent <DockingPort>().Undock());

                var server = networkMember as GameServer;
                if (server == null)
                {
                    return;
                }

                //shuttle has returned if the path has been traversed or the shuttle is close enough to the exit

                if (!CoroutineManager.IsCoroutineRunning("forcepos"))
                {
                    if ((shuttleSteering?.SteeringPath != null && shuttleSteering.SteeringPath.Finished) ||
                        (respawnShuttle.WorldPosition.Y + respawnShuttle.Borders.Y > Level.Loaded.StartPosition.Y - Level.ShaftHeight &&
                         Math.Abs(Level.Loaded.StartPosition.X - respawnShuttle.WorldPosition.X) < 1000.0f))
                    {
                        CoroutineManager.StopCoroutines("forcepos");
                        CoroutineManager.StartCoroutine(
                            ForceShuttleToPos(new Vector2(Level.Loaded.StartPosition.X, Level.Loaded.Size.Y + 1000.0f), 100.0f), "forcepos");
                    }
                }

                if (respawnShuttle.WorldPosition.Y > Level.Loaded.Size.Y || shuttleReturnTimer <= 0.0f)
                {
                    CoroutineManager.StopCoroutines("forcepos");

                    ResetShuttle();

                    state = State.Waiting;
                    GameServer.Log("The respawn shuttle has left.", ServerLog.MessageType.Spawning);
                    server.CreateEntityEvent(this);

                    respawnTimer     = respawnInterval;
                    CountdownStarted = false;
                }
            }
        }
Beispiel #3
0
        public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power = 0.0f)
        {
            if (isStuck)
            {
                return;
            }

            bool wasOpen = predictedState == null ? isOpen : predictedState.Value;

            if (connection.Name == "toggle")
            {
                SetState(!wasOpen, false, true);
            }
            else if (connection.Name == "set_state")
            {
                SetState(signal != "0", false, true);
            }

            bool newState = predictedState == null ? isOpen : predictedState.Value;

            if (GameMain.Server != null && sender != null && wasOpen != newState)
            {
                if (linkedGap != null && !linkedGap.IsRoomToRoom)
                {
                    if (CoroutineManager.IsCoroutineRunning("WarnAirlockLeftOpen_" + item.ID))
                    {
                        CoroutineManager.StopCoroutines("WarnAirlockLeftOpen_" + item.ID);
                    }

                    //This is on a respawn shuttle
                    if (GameMain.Server.RespawnManager != null && GameMain.Server.RespawnManager.Submarine != null &&
                        item.Submarine == GameMain.Server.RespawnManager.Submarine)
                    {
                        GameServer.Log(sender.LogName + (newState ? " opened respawn shuttle exterior " : " closed respawn shuttle exterior ") + item.Name, ServerLog.MessageType.ItemInteraction);

                        if (GameMain.NilMod.EnableGriefWatcher && newState)
                        {
                            Barotrauma.Networking.Client warnedclient = GameMain.Server.ConnectedClients.Find(c => c.Character == sender);

                            CoroutineManager.StartCoroutine(WarnAirlockLeftOpen(warnedclient, this, true), "WarnAirlockLeftOpen_" + item.ID);
                        }
                    }
                    //This is a regular shuttle or submarine
                    else if (item.Submarine != null)
                    {
                        GameServer.Log(sender.LogName + (newState ? " opened " + item.Submarine.Name + " exterior " : " closed " + item.Submarine.Name + " exterior ") + item.Name, ServerLog.MessageType.ItemInteraction);

                        if (GameMain.NilMod.EnableGriefWatcher && newState)
                        {
                            Barotrauma.Networking.Client warnedclient = GameMain.Server.ConnectedClients.Find(c => c.Character == sender);

                            CoroutineManager.StartCoroutine(WarnAirlockLeftOpen(warnedclient, this, false), "WarnAirlockLeftOpen_" + item.ID);
                        }
                    }
                }
                else
                {
                    //This is on a respawn shuttle
                    if (GameMain.Server.RespawnManager != null && GameMain.Server.RespawnManager.Submarine != null &&
                        item.Submarine == GameMain.Server.RespawnManager.Submarine)
                    {
                        GameServer.Log(sender.LogName + (newState ? " opened respawn shuttle interior " : " closed respawn shuttle interior ") + item.Name, ServerLog.MessageType.ItemInteraction);
                    }
                    //This is a regular shuttle or submarine
                    else if (item.Submarine != null)
                    {
                        GameServer.Log(sender.LogName + (newState ? " opened " + item.Submarine.Name + " interior " : " closed " + item.Submarine.Name + " interior ") + item.Name, ServerLog.MessageType.ItemInteraction);
                    }
                }
            }
        }