////////////////

        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (Main.netMode == 2)
            {
                throw new HamstarException("No server.");
            }

            var mymod = (OnARailMod)this.mod;

            if (!mymod.Config.DebugModeEnableTrainRespawnCommand)
            {
                if (!UserHelpers.HasBasicServerPrivilege(caller.Player))
                {
                    caller.Reply("Train respawning disabled by config.", Color.Red);
                    return;
                }
                else
                {
                    Main.NewText("Priviledged player " + caller.Player.name + " respawns train.", Color.LightSteelBlue);
                }
            }

            int who = TrainEntity.FindMyTrain(caller.Player);

            if (who != -1)
            {
                CustomEntityManager.RemoveEntityByWho(who);
            }

            PacketProtocolRequestToServer.QuickRequest <TrainSpawnProtocol>();

            caller.Reply("Spawning train...", Color.LimeGreen);
        }
 private void OnConnectHost()
 {
     //Promises.AddPostWorldLoadOncePromise( () => {
     Promises.AddValidatedPromise(SaveableEntityComponent.LoadAllValidator, () => {
         if (TrainEntity.FindMyTrain(this.player) == -1)
         {
             var ent = TrainEntity.CreateTrainEntity(this.player);
             CustomEntityManager.AddToWorld(ent);
         }
         return(false);
     });
 }
Beispiel #3
0
        public override void PreUpdate()
        {
            if (SaveableEntityComponent.HaveAllEntitiesLoaded)
            {
                if (this.MyTrainWho == -1)
                {
                    this.MyTrainWho = TrainEntity.FindMyTrain(this.player);
                }

                if (this.MyTrainWho != -1)
                {
                    this.UpdatePostTrainLoad();
                }
            }

            this.UpdatePlayerState();
        }
Beispiel #4
0
        ////////////////

        protected override bool ReceiveRequestWithServer(int from_who)
        {
            Player player = Main.player[from_who];

            Promises.AddValidatedPromise(SaveableEntityComponent.LoadAllValidator, () => {
                if (TrainEntity.FindMyTrain(player) != -1)
                {
                    throw new HamstarException("Cannot spawn duplicate train for player " + player.name);
                }

                var ent = TrainEntity.CreateTrainEntity(player);
                CustomEntityManager.AddToWorld(ent);

                return(false);
            });

            return(true);
        }