Exemplo n.º 1
0
        public override void OnDirectInput(SnapObj_PlayerInput input)
        {
            if (input.PlayerFlags.HasFlag(PlayerFlags.PLAYERFLAG_CHATTING))
            {
                if (PlayerFlags.HasFlag(PlayerFlags.PLAYERFLAG_CHATTING))
                {
                    return;
                }

                Character?.ResetInput();
                PlayerFlags = input.PlayerFlags;
                return;
            }

            PlayerFlags = input.PlayerFlags;
            Character?.OnDirectInput(input);

            if (Character == null && Team != Team.SPECTATORS && (input.Fire & 1) != 0)
            {
                Spawning = true;
            }

            if (input.Direction != 0 ||
                input.Jump ||
                input.Hook ||
                LatestActivity.TargetX != input.TargetX ||
                LatestActivity.TargetY != input.TargetY ||
                (input.Fire & 1) != 0)
            {
                LatestActivity.TargetX = input.TargetX;
                LatestActivity.TargetY = input.TargetY;
                LastActionTick         = Server.Tick;
            }
        }
Exemplo n.º 2
0
        public override void Deserialize(int[] data, int dataOffset)
        {
            if (!RangeCheck(data, dataOffset))
            {
                return;
            }

            Tick = data[dataOffset + 0];
            PosX = data[dataOffset + 1];
            PosY = data[dataOffset + 2];
            VelX = data[dataOffset + 3];
            VelY = data[dataOffset + 4];

            Angle        = data[dataOffset + 5];
            Direction    = data[dataOffset + 6];
            Jumped       = data[dataOffset + 7];
            HookedPlayer = data[dataOffset + 8];
            HookState    = (HookState)data[dataOffset + 9];
            HookTick     = data[dataOffset + 10];
            HookX        = data[dataOffset + 11];
            HookY        = data[dataOffset + 12];
            HookDx       = data[dataOffset + 13];
            HookDy       = data[dataOffset + 14];

            PlayerFlags = (PlayerFlags)data[dataOffset + 15];
            Health      = data[dataOffset + 16];
            Armor       = data[dataOffset + 17];
            AmmoCount   = data[dataOffset + 18];
            Weapon      = (Weapon)data[dataOffset + 19];
            Emote       = (Emote)data[dataOffset + 20];
            AttackTick  = data[dataOffset + 21];
        }
Exemplo n.º 3
0
 private static void InputSource_OnPressedEvent(Key KeyEvent, PlayerFlags Player)
 {
     foreach (string ActionName in MatchBinding(KeyEvent))
     {
         CallActionEvent(ActionName, InputEvent.Pressed);
     }
 }
Exemplo n.º 4
0
 public void OnTravel(Node to)
 {
     if (to == destination && PlayerFlags.HasFlag(hasFlag))
     {
         onTravelTo.Invoke();
     }
 }
Exemplo n.º 5
0
        public override void PostTick()
        {
            if (PlayerFlags.HasFlag(PlayerFlags.Scoreboard))
            {
                for (var i = 0; i < GameContext.Players.Length; i++)
                {
                    if (GameContext.Players[i] != null &&
                        GameContext.Players[i].Team != Team.Spectators)
                    {
                        ActualLatency[i] = GameContext.Players[i].Latency.Min;
                    }
                }
            }

            if ((Team == Team.Spectators || DeadSpectatorMode) && SpectatorMode != SpectatorMode.FreeView)
            {
                if (SpectatorFlag != null)
                {
                    ViewPos = SpectatorFlag.Position;
                }
                else if (GameContext.Players[SpectatorId] != null)
                {
                    ViewPos = GameContext.Players[SpectatorId].ViewPos;
                }
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Creates a new player flags packet.
 /// </summary>
 /// <param name="buffer">A buffer contaning the packet data.</param>
 public IS_PFL(byte[] buffer)
     : this() {
     PacketReader reader = new PacketReader(buffer);
     Size = reader.ReadByte();
     Type = (PacketType)reader.ReadByte();
     ReqI = reader.ReadByte();
     PLID = reader.ReadByte();
     Flags = (PlayerFlags)reader.ReadUInt16();
 }
Exemplo n.º 7
0
    public static void UpdateSaveData()
    {
        currSave = currSave ?? new GameSave();

        currSave.flags = PlayerFlags.GetFlags();
        //currSave.currentNode = Map.WorldMap.Instance.CurrentNodeName();
        currSave.currentSequence = EventSequencer.CurrentSequence;
        currSave.currentParty    = PartyManager.CurrentParty;
    }
Exemplo n.º 8
0
        public bool PollInput(WTKey KeyName, PlayerFlags Player)
        {
            if (lastInputSnapshot.KeyEvents.Count(x => x.Key == KeyName.Convert()) > 0)
            {
                return(lastInputSnapshot.KeyEvents.First(x => x.Key == KeyName.Convert()).Down);
            }
            return(lastInputSnapshot.IsMouseDown(KeyName.ConvertMouse()));

            //return false;
        }
Exemplo n.º 9
0
        public override void OnPredictedInput(SnapshotPlayerInput input)
        {
            // ignore input when player chat open
            if (PlayerFlags.HasFlag(PlayerFlags.Chatting) && input.PlayerFlags.HasFlag(PlayerFlags.Chatting))
            {
                return;
            }

            Character?.OnPredictedInput(input);
        }
Exemplo n.º 10
0
 //reload save data into game from the currently open save
 public static void RestoreFromOpenSave()
 {
     if (!IsSaveLoaded())
     {
         return;
     }
     PlayerFlags.LoadFlags(currSave.flags);
     Map.WorldMap.Instance.SetCurrentNode(GameObject.Find(currSave.currentNode).GetComponent <Map.Node>());
     EventSequencer.CurrentSequence = currSave.currentSequence;
     PartyManager.CurrentParty      = currSave.currentParty;
 }
Exemplo n.º 11
0
        /// <summary>
        /// Creates a new player flags packet.
        /// </summary>
        /// <param name="buffer">A buffer contaning the packet data.</param>
        public IS_PFL(byte[] buffer)
            : this()
        {
            PacketReader reader = new PacketReader(buffer);

            Size  = reader.ReadByte();
            Type  = (PacketType)reader.ReadByte();
            ReqI  = reader.ReadByte();
            PLID  = reader.ReadByte();
            Flags = (PlayerFlags)reader.ReadUInt16();
        }
Exemplo n.º 12
0
        public override void OnPredictedInput(SnapObj_PlayerInput input)
        {
            // ignore input when player chat open
            if (PlayerFlags.HasFlag(PlayerFlags.PLAYERFLAG_CHATTING) &&
                input.PlayerFlags.HasFlag(PlayerFlags.PLAYERFLAG_CHATTING))
            {
                return;
            }

            Character?.OnPredictedInput(input);
        }
Exemplo n.º 13
0
        public static bool IsKeyDown(Key KeyEvent, PlayerFlags Player = PlayerFlags.ANY_PLAYER)
        {
            bool KeyDown = false;

            foreach (IInputSource source in InputSources)
            {
                KeyDown |= source.PollInput(KeyEvent, Player);
            }

            return(KeyDown);
        }
Exemplo n.º 14
0
        public static float PollAxis(Key AxisKey, PlayerFlags Player = PlayerFlags.ANY_PLAYER)
        {
            float AxisValue = 0.0f;

            foreach (IInputSource source in InputSources)
            {
                AxisValue += source.PollAxis(AxisKey, Player);
            }

            return(AxisValue);
        }
 public float PollAxis(Key KeyName, PlayerFlags Player)
 {
     if (PollInput(KeyName, Player))
     {
         return(1.0f);
     }
     else
     {
         return(0.0f);
     }
 }
Exemplo n.º 16
0
        private void RpgInit()
        {
            //Debug.LogWarning(nameof(RpgInit));

            //TODO better debugging and logging

            //load initial player
            try
            {
                instance.PlayerRpgState = new CharacterModel();
                JsonConvert.PopulateObject(CoreUtils.LoadResource <TextAsset>("Data/RPGDefs/init_player").text, instance.PlayerRpgState, new JsonSerializerSettings
                {
                    Converters        = CCJsonConverters.Defaults.Converters,
                    TypeNameHandling  = TypeNameHandling.Auto,
                    NullValueHandling = NullValueHandling.Ignore
                });
                instance.PlayerRpgState.UpdateStats();
                PlayerFlags.RegisterSource(instance.PlayerRpgState);
            }
            catch (Exception e)
            {
                Debug.LogError("Failed to load initial player");
                Debug.LogException(e);
            }

            //load initial containers (requires some decoding)
            //we will actually need to load additional containers ex post facto when we add mod support
            try
            {
                var rawContainers = CoreUtils.LoadJson <Dictionary <string, SerializableContainerModel> >(CoreUtils.LoadResource <TextAsset>("Data/RPGDefs/init_containers").text);
                foreach (var key in rawContainers.Keys)
                {
                    var value = rawContainers[key];
                    try
                    {
                        var realContainer = SerializableContainerModel.MakeContainerModel(value);
                        instance.ContainerState.Add(key, realContainer);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("Failed to load one container");
                        Debug.LogException(e);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogError("Failed to load initial container state");
                Debug.LogException(e);
            }

            instance.InitialLoaded = true;
        }
Exemplo n.º 17
0
        public override void Dispose()
        {
            if (this.IsDisposed)
            {
                return;
            }

            base.Dispose();

            this.GateSessionId = 0;
            this.IsNetSync     = true;
            this.Flags         = PlayerFlags.Player;
        }
Exemplo n.º 18
0
 public void Reset()
 {
     Direction    = 0;
     TargetX      = 0;
     TargetY      = 0;
     Jump         = false;
     Fire         = 0;
     Hook         = false;
     PlayerFlags  = 0;
     WantedWeapon = 0;
     NextWeapon   = 0;
     PrevWeapon   = 0;
 }
Exemplo n.º 19
0
 public void FillFrom(SnapObj_PlayerInput other)
 {
     Direction    = other.Direction;
     TargetX      = other.TargetX;
     TargetY      = other.TargetY;
     Jump         = other.Jump;
     Fire         = other.Fire;
     Hook         = other.Hook;
     PlayerFlags  = other.PlayerFlags;
     WantedWeapon = other.WantedWeapon;
     NextWeapon   = other.NextWeapon;
     PrevWeapon   = other.PrevWeapon;
 }
Exemplo n.º 20
0
 public FullSave(PlayerSave player, PosSave pos, List <DormSave> dorm, HomeSave parHome, VoreSaves vore, List <TeleportSave> teleportSaves)
 {
     this.playerPart    = player;
     this.posPart       = pos;
     this.dormPart      = dorm;
     this.datePart      = DateSystem.Save;
     this.homePart      = parHome;
     this.voreSaves     = vore;
     this.questSave     = QuestsSystem.Save;
     this.playerFlags   = PlayerFlags.Save();
     this.teleportSaves = teleportSaves;
     this.gameManager   = GameManager.Save();
 }
Exemplo n.º 21
0
 public IS_FIN(byte[] data) {
     Size = data[0];
     Type = (PacketType)data[1];
     ReqI = data[2];
     PLID = data[3];
     TTime = BitConverter.ToUInt32(data, 4);
     BTime = BitConverter.ToUInt32(data, 8);
     SpA = data[12];
     NumStops = data[13];
     Confirm = (ConfirmationFlags)data[14];
     SpB = data[15];
     LapsDone = BitConverter.ToUInt16(data, 16);
     Flags = (PlayerFlags)BitConverter.ToUInt16(data, 18);
 }
Exemplo n.º 22
0
        public bool CanTravelTo(Node to)
        {
            if (to == null)
            {
                return(false);
            }
            int index = travelNodes.FindIndex(naf => naf.node == to);

            if (index == -1 || !PlayerFlags.HasFlag(travelNodes[index].flag))
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 23
0
        public float PollAxis(Key KeyName, PlayerFlags Player)
        {
            Vector2i MousePos = Mouse.GetPosition(SFMLRenderer.Instance.Window);

            if (KeyName == Key.MouseX)
            {
                return(MousePos.X);
            }
            if (KeyName == Key.MouseY)
            {
                return(MousePos.Y);
            }

            return(PollInput(KeyName, Player) ? 1.0f : 0.0f);
        }
Exemplo n.º 24
0
        public void Reset()
        {
            RoomReference = new Reference <Room> {
                Id = "Rooms/1"
            };

            Items.Clear();
            Spells.Clear();

            Level     = 1;
            Gold      = 0;
            CurrentHp = MaxHp = 10;
            CurrentMp = MaxMp = 10;

            PlayerStatus = new PlayerFlags();
        }
Exemplo n.º 25
0
        public static string [] PlayerFlagsArray(int Value)
        {
            string []   values;
            string      value_list;
            PlayerFlags pf_mask = (PlayerFlags)Value;

            value_list = pf_mask.ToString("G");
            values     = value_list.Split(',');

            for (int i = 0; i < values.Length; i++)
            {
                values[i] = values[i].Trim();
            }

            return(values);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Creates a new finished race notification packet.
        /// </summary>
        /// <param name="buffer">A buffer contaning the packet data.</param>
        public IS_FIN(byte[] buffer)
            : this()
        {
            PacketReader reader = new PacketReader(buffer);

            Size  = reader.ReadByte();
            Type  = (PacketType)reader.ReadByte();
            ReqI  = reader.ReadByte();
            PLID  = reader.ReadByte();
            TTime = TimeSpan.FromMilliseconds(reader.ReadUInt32());
            BTime = TimeSpan.FromMilliseconds(reader.ReadUInt32());
            reader.Skip(1);
            NumStops = reader.ReadByte();
            Confirm  = (ConfirmationFlags)reader.ReadByte();
            reader.Skip(1);
            LapsDone = reader.ReadUInt16();
            Flags    = (PlayerFlags)reader.ReadUInt16();
        }
Exemplo n.º 27
0
        public override void Deserialize(int[] data, int dataOffset)
        {
            if (!RangeCheck(data, dataOffset))
            {
                return;
            }

            Direction    = data[dataOffset + 0];
            TargetX      = data[dataOffset + 1];
            TargetY      = data[dataOffset + 2];
            Jump         = data[dataOffset + 3] != 0;
            Fire         = data[dataOffset + 4];
            Hook         = data[dataOffset + 5] != 0;
            PlayerFlags  = (PlayerFlags)data[dataOffset + 6];
            WantedWeapon = data[dataOffset + 7];
            NextWeapon   = data[dataOffset + 8];
            PrevWeapon   = data[dataOffset + 9];
        }
Exemplo n.º 28
0
 public void BeginSequence()
 {
     if (!PlayerFlags.HasFlag(hasFlag) || PlayerFlags.HasAnyFlag(doesntHaveFlag))
     {
         ended = true;
         return;
     }
     ended = false;
     functionOnStart.Invoke();
     if (sequence != null)
     {
         (sequence as ISequence).BeginSequence();
         StartCoroutine(WaitUntilSeqEndCoroutine());
     }
     else
     {
         StartCoroutine(WaitUntilTimeCoroutine());
     }
 }
Exemplo n.º 29
0
        public override void PostTick()
        {
            if (PlayerFlags.HasFlag(PlayerFlags.PLAYERFLAG_SCOREBOARD))
            {
                for (var i = 0; i < GameContext.Players.Length; i++)
                {
                    if (GameContext.Players[i] != null &&
                        GameContext.Players[i].Team != Team.SPECTATORS)
                    {
                        ActLatency[i] = GameContext.Players[i].Latency.Min;
                    }
                }
            }

            if (SpectatorId >= 0 && Team == Team.SPECTATORS && GameContext.Players[SpectatorId] != null)
            {
                ViewPos = GameContext.Players[SpectatorId].ViewPos;
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// Initializes the player from initial state
        /// </summary>
        public void InitializePlayer(string jsonData)
        {
            if (instance.PlayerRpgState != null && PlayerFlags.HasSource(instance.PlayerRpgState))
            {
                PlayerFlags.UnregisterSource(instance.PlayerRpgState);
            }

            instance.PlayerRpgState = new CharacterModel();
            JsonConvert.PopulateObject(jsonData, instance.PlayerRpgState, new JsonSerializerSettings
            {
                Converters        = CCJsonConverters.Defaults.Converters,
                TypeNameHandling  = TypeNameHandling.Auto,
                NullValueHandling = NullValueHandling.Ignore
            });
            instance.PlayerRpgState.FormID = "Player";
            InventoryModel.AssignUIDs(instance.PlayerRpgState.Inventory.EnumerateItems(), true);
            instance.PlayerRpgState.UpdateStats();
            PlayerFlags.RegisterSource(instance.PlayerRpgState);
        }
Exemplo n.º 31
0
    public void LoadData(string json)
    {
        FullSave fullSave = JsonUtility.FromJson <FullSave>(json);

        // Singleton static
        // Reference
        JsonUtility.FromJsonOverwrite(fullSave.PlayerPart.Who, Player);
        StartHomeStats.Load(fullSave.HomePart);
        dorm.Load(fullSave.DormPart);
        voreChar.Load(fullSave.VoreSaves, Player);
        // Pure static
        DateSystem.Load(fullSave.DatePart);
        QuestsSystem.Load(fullSave.QuestSave);
        PlayerFlags.Load(fullSave.PlayerFlagsSave);
        MapEvents.GetMapEvents.Load(fullSave.PosPart, fullSave.TeleportSaves);
        GameManager.Load(fullSave.GameManagerSave);
        EventLog.ClearLog();
        LoadEvent?.Invoke();
    }
Exemplo n.º 32
0
        private void ModifyPlayerFlags(BasePlayer player, bool addFlag, PlayerFlags flag)
        {
            bool actionCompleted = false;

            if (addFlag)
            {
                if ((playersInfo[player.userID].flags & flag) != flag)
                {
                    playersInfo[player.userID].flags |= flag;
                    actionCompleted = true;
                }
            }
            else
            {
                if ((playersInfo[player.userID].flags & flag) == flag)
                {
                    playersInfo[player.userID].flags &= ~flag;
                    actionCompleted = true;
                }
            }

            if (actionCompleted)
            {
                string msg = "";
                switch (flag)
                {
                case PlayerFlags.ICONS_DISABLED:
                    msg += "ICONS";
                    break;

                case PlayerFlags.PLUGIN_DISABLED:
                    msg += "PLUGIN";
                    break;

                case PlayerFlags.MESSAGES_DISABLED:
                    msg += "MESSAGES";
                    break;
                }
                SendReply(player, pluginPrefix + msg + " has been " + (!addFlag? "ENABLED" : "DISABLED") + ".");
            }
        }
Exemplo n.º 33
0
 public void RemoveFlag(PlayerFlags flag)
 {
     Flags &= ~flag;
 }
Exemplo n.º 34
0
 public bool HasFlag(PlayerFlags flag)
 {
     return (this[PlayerField.PLAYER_FLAGS] & (uint)flag) != 0;
 }
Exemplo n.º 35
0
 public void SetPlayerFlag(PlayerFlags flag)
 {
     CharacterSpecials.Saved.Flags = CharacterSpecials.Saved.Flags | (byte)flag;
 }
Exemplo n.º 36
0
 public void RemovePlayerFlag(PlayerFlags flag)
 {
     CharacterSpecials.Saved.Flags &= ~(byte)flag;
 }
Exemplo n.º 37
0
 public bool PlayerFlagged(PlayerFlags flag)
 {
     return ((CharacterSpecials.Saved.Flags & (byte)flag) == (byte)flag);
 }
Exemplo n.º 38
0
		public static bool HasFlag(this PlayerFlags flags, PlayerFlags toCheck)
		{
			return (flags & toCheck) != 0;
		}
        private void ModifyPlayerFlags(BasePlayer player, bool addFlag, PlayerFlags flag)
        {
            bool actionCompleted = false;
            if (addFlag)
            {
                if ((playersInfo[player.userID].flags & flag) != flag)
                {
                    playersInfo[player.userID].flags |= flag;
                    actionCompleted = true;
                }
            }
            else
            {
                if ((playersInfo[player.userID].flags & flag) == flag)
                {
                    playersInfo[player.userID].flags &= ~flag;
                    actionCompleted = true;
                }
            }

            if (actionCompleted)
            {
                string msg = "";
                switch (flag)
                {
                    case PlayerFlags.ICONS_DISABLED:
                        msg += "ICONS";
                        break;
                    case PlayerFlags.PLUGIN_DISABLED:
                        msg += "PLUGIN";
                        break;
                    case PlayerFlags.MESSAGES_DISABLED:
                        msg += "MESSAGES";
                        break;
                }
                SendReply(player, pluginPrefix + msg + " has been " + (!addFlag? "ENABLED" : "DISABLED") + ".");
            }
        }
Exemplo n.º 40
0
 public bool HasFlag(PlayerFlags flag)
 {
     return (Flags & flag) != 0;
 }
Exemplo n.º 41
0
 /// <summary>
 /// Creates a new finished race notification packet.
 /// </summary>
 /// <param name="buffer">A buffer contaning the packet data.</param>
 public IS_FIN(byte[] buffer)
     : this() {
     PacketReader reader = new PacketReader(buffer);
     Size = reader.ReadByte();
     Type = (PacketType)reader.ReadByte();
     ReqI = reader.ReadByte();
     PLID = reader.ReadByte();
     TTime = TimeSpan.FromMilliseconds(reader.ReadUInt32());
     BTime = TimeSpan.FromMilliseconds(reader.ReadUInt32());
     reader.Skip(1);
     NumStops = reader.ReadByte();
     Confirm = (ConfirmationFlags)reader.ReadByte();
     reader.Skip(1);
     LapsDone = reader.ReadUInt16();
     Flags = (PlayerFlags)reader.ReadUInt16();
 }
 private bool PlayerHasFlag(ulong userID, PlayerFlags flag)
 {
     return (GetPlayerFlags(userID) & flag) == flag;
 }