Пример #1
0
 public UserActionProvider(IFacebookClientProvider facebookClientProvider, IPlayerReadModel playerReadModel, IPlayerSession playerSession, ICommandSender bus)
 {
     _facebookClientProvider = facebookClientProvider;
     _playerReadModel = playerReadModel;
     _playerSession = playerSession;
     _bus = bus;
 }
        public void Setup()
        {
            _session = Substitute.For<IPlayerSession>();
            _bus = Substitute.For<ICommandSender>();
            _playerReadModel = Substitute.For<IPlayerReadModel>();

            _target = new NativeUserActions(_session, _bus, _playerReadModel);
        }
Пример #3
0
        public void Setup()
        {
            _session = Substitute.For<IPlayerSession>();

            var locator = Substitute.For<IServiceLocator>();
            locator.GetInstance<IPlayerSession>().Returns(_session);
            ServiceLocator.SetLocatorProvider(() => locator);

            _target = new PlayerRequired();
        }
 public override void SetParameter(ComponentParameter parameter)
 {
     switch (parameter.MemberName)
     {
         case "playersession": //TODO this shouldnt be a parameter.
             playerSession = parameter.GetValue<IPlayerSession>();
             break;
         default:
             base.SetParameter(parameter);
             break;
     }
 }
Пример #5
0
 public void SpawnPlayerMob(IPlayerSession s)
 {
     //Spawn the player's entity. There's probably a much better place to do this.
     Entity a = server.EntityManager.SpawnEntity("HumanMob");
     Entity human = a;
     a.GetComponent<ITransformComponent>(ComponentFamily.Transform).TranslateTo(new Vector2(0, 0));
     if (s.assignedJob != null)
     {
         foreach (
             Entity newItem in
                 s.assignedJob.SpawnEquipment.Select(def => server.EntityManager.SpawnEntity(def.ObjectType)))
         {
             newItem.GetComponent<ITransformComponent>(ComponentFamily.Transform).TranslateTo(
                 human.GetComponent<ITransformComponent>(ComponentFamily.Transform).Position);
             human.GetComponent<IEquipmentComponent>(ComponentFamily.Equipment).RaiseEquipItem(newItem);
         }
     }
     s.AttachToEntity(a);
 }
Пример #6
0
 public NativeUserActions(IPlayerSession session, ICommandSender bus, IPlayerReadModel playerReadModel)
 {
     _session = session;
     _bus = bus;
     _playerReadModel = playerReadModel;
 }
Пример #7
0
        /// <summary>
        ///     Detaches this player from its attached entity, if any.
        /// </summary>
        /// <param name="player">The player session that will be detached from any attached entities.</param>
        /// <returns>Whether the player is now detached from any entities.
        /// This returns true if the player wasn't attached to any entity.</returns>
        public bool Detach(IPlayerSession player)
        {
            var uid = player.AttachedEntityUid;

            return(uid == null || Detach(uid.Value));
        }
Пример #8
0
 private void UpdateSurgeryUIBodyPartSlotRequest(IPlayerSession session, Dictionary <string, int> options)
 {
     UserInterface?.SendMessage(new RequestBodyPartSlotSurgeryUIMessage(options), session);
 }
Пример #9
0
 //Called by SendMap() after sending everything.
 public virtual void SpawnPlayer(IPlayerSession player)
 {
     //This should be handled differently!!!.
     IoCManager.Resolve<IPlayerManager>().SpawnPlayerMob(player);
 }
Пример #10
0
 public bool CanScript(IPlayerSession session)
 {
     return(Implementation?.CanScript(session) ?? false);
 }
Пример #11
0
 public ViewSubscriberRemovedEvent(EntityUid view, IPlayerSession subscriber)
 {
     View       = view;
     Subscriber = subscriber;
 }
Пример #12
0
 public bool CanScript(IPlayerSession session)
 {
     return(IsLocal(session));
 }
Пример #13
0
 public bool CanCommand(IPlayerSession session, string cmdName)
 {
     return(Implementation?.CanCommand(session, cmdName) ?? false);
 }
Пример #14
0
 public bool CanCommand(IPlayerSession session, string cmdName)
 {
     return(IsLocal(session));
 }
Пример #15
0
 public bool CanViewVar(IPlayerSession session)
 {
     return(IsLocal(session));
 }
Пример #16
0
 private static string FormatPlayerString(IPlayerSession session)
 {
     return(session != null ? $"{session.Name}" : "[HOST]");
 }
Пример #17
0
        public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
        {
            var ticker = IoCManager.Resolve <IGameTicker>();

            ticker.RestartRound();
        }
Пример #18
0
        public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
        {
            if (args.Length == 0)
            {
                shell.SendText(player, Help);
                return;
            }

            if (player.AttachedEntity == null)
            {
                shell.SendText(player, "You don't have a player!");
                return;
            }

            var compFactory = IoCManager.Resolve <IComponentFactory>();

            if (args[0] == "?")
            {
                // Get all components that implement the ISpeechComponent except
                var speeches = compFactory.GetAllRefTypes()
                               .Where(c => typeof(IAccentComponent).IsAssignableFrom(c) && c.IsClass);
                var msg = "";
                foreach (var s in speeches)
                {
                    msg += $"{compFactory.GetRegistration(s).Name}\n";
                }
                shell.SendText(player, msg);
            }
            else
            {
                var name = args[0];
                // Try to get the Component
                Type type;
                try
                {
                    var comp = compFactory.GetComponent(name);
                    type = comp.GetType();
                }
                catch (Exception)
                {
                    shell.SendText(player, $"Accent {name} not found. Try {Command} ? to get a list of all appliable accents.");
                    return;
                }

                // Check if that already exists
                try
                {
                    var comp = player.AttachedEntity.GetComponent(type);
                    shell.SendText(player, "You already have this accent!");
                    return;
                }
                catch (Exception)
                {
                    // Accent not found
                }

                // Generic fuckery
                var ensure = typeof(IEntity).GetMethod("AddComponent");
                if (ensure == null)
                {
                    return;
                }
                var method = ensure.MakeGenericMethod(type);
                method.Invoke(player.AttachedEntity, null);
            }
        }
Пример #19
0
 public AdminReg(IPlayerSession session, AdminData data)
 {
     Data    = data;
     Session = session;
 }
Пример #20
0
 public bool CanAdminMenu(IPlayerSession session)
 {
     return(IsLocal(session));
 }
Пример #21
0
 private void UpdatePlayerStatus(IPlayerSession session)
 {
     UserInterface?.SendMessage(new BlockGameMessages.BlockGameUserStatusMessage(_player == session), session);
 }
Пример #22
0
 public bool CanAdminReloadPrototypes(IPlayerSession session)
 {
     return(IsLocal(session));
 }
Пример #23
0
 public bool CanViewVar(IPlayerSession session)
 {
     return(Implementation?.CanViewVar(session) ?? false);
 }
 public void OpenUserInterface(IPlayerSession session)
 {
     UserInterface?.Open(session);
 }
Пример #25
0
 public bool CanAdminMenu(IPlayerSession session)
 {
     return(Implementation?.CanAdminMenu(session) ?? false);
 }
Пример #26
0
 public ServerBoundUserInterfaceMessage(BoundUserInterfaceMessage message, IPlayerSession session)
 {
     Message = message;
     Session = session;
 }
Пример #27
0
 private void OpenSurgeryUI(IPlayerSession session)
 {
     UserInterface?.Open(session);
 }
Пример #28
0
 internal void SendToSession(IPlayerSession session, BoundUserInterfaceMessage message, object uiKey)
 {
     SendNetworkMessage(new BoundInterfaceMessageWrapMessage(message, uiKey), session.ConnectedClient);
 }
Пример #29
0
 private void CloseSurgeryUI(IPlayerSession session)
 {
     UserInterface?.Close(session);
 }
Пример #30
0
 public PlayerDetachedEvent(IEntity entity, IPlayerSession player)
 {
     Entity    = entity;
     EntityUid = entity.Uid;
     Player    = player;
 }
Пример #31
0
 public void SpawnPlayer(IPlayerSession player)
 {
     if (!_ready) return;
     CurrentGameMode.SpawnPlayer(player);
     CurrentGameMode.PlayerJoined(player);
 }
Пример #32
0
 public virtual void PlayerJoined(IPlayerSession player)
 {
 }
Пример #33
0
 public void SpawnPlayerMob(IPlayerSession s)
 {
     //Spawn the player's entity. There's probably a much better place to do this.
     Entity a = server.EntityManager.SpawnEntity("HumanMob");
     Entity human = a;
     a.GetComponent<ITransformComponent>(ComponentFamily.Transform).TranslateTo(new Vector2(160, 160));
     if (s.assignedJob != null)
     {
         foreach (
             Entity newItem in
                 s.assignedJob.SpawnEquipment.Select(def => server.EntityManager.SpawnEntity(def.ObjectType)))
         {
             newItem.GetComponent<ITransformComponent>(ComponentFamily.Transform).TranslateTo(
                 human.GetComponent<ITransformComponent>(ComponentFamily.Transform).Position);
             //This is not neccessary once the equipment component is built.
             human.SendMessage(this, ComponentMessageType.EquipItem, newItem);
         }
     }
     s.AttachToEntity(a);
 }
Пример #34
0
 public AttachPlayerEvent(EntityUid uid, IPlayerSession player, bool force = false)
 {
     Uid    = uid;
     Player = player;
     Force  = force;
 }
Пример #35
0
 private void OnPlayerStatusChanged(IPlayerSession session, SessionStatus oldStatus, SessionStatus newStatus)
 {
     PlayerStatusChanged?.Invoke(this, new SessionStatusEventArgs(session, oldStatus, newStatus));
 }
Пример #36
0
 /// <summary>
 ///     Attaches a player session to an entity, optionally kicking any sessions already attached to it.
 /// </summary>
 /// <param name="uid">The entity to attach the player to</param>
 /// <param name="player">The player to attach to the entity</param>
 /// <param name="force">Whether to kick any existing players from the entity</param>
 /// <returns>Whether the attach succeeded, or not.</returns>
 public bool Attach(EntityUid uid, IPlayerSession player, bool force = false)
 {
     return(Attach(uid, player, false, out _));
 }
Пример #37
0
 public virtual void SpawnPlayer(IPlayerSession player) //Called by SendMap() after sending everything.
 {
     //This should be handled differently!!!.
     IoCManager.Resolve<IPlayerManager>().SpawnPlayerMob(player);
 }
Пример #38
0
 public SessionStatusEventArgs(IPlayerSession session, SessionStatus oldStatus, SessionStatus newStatus)
 {
     Session   = session;
     OldStatus = oldStatus;
     NewStatus = newStatus;
 }
Пример #39
0
 public virtual void PlayerDied(IPlayerSession player)
 {
     IoCManager.Resolve<IChatManager>().SendChatMessage(ChatChannel.Server, "Gamemode: Player died!", null,
                                                        player.AttachedEntityUid);
 }
 public void OpenSurgeryUI(IPlayerSession session)
 {
     _userInterface.Open(session);
 }
 public void CloseSurgeryUI(IPlayerSession session)
 {
     _userInterface.Close(session);
 }
Пример #42
0
 /// <summary>
 ///     Attaches a player session to an entity, optionally kicking any sessions already attached to it.
 /// </summary>
 /// <param name="entity">The entity to attach the player to</param>
 /// <param name="player">The player to attach to the entity</param>
 /// <param name="force">Whether to kick any existing players from the entity</param>
 /// <returns>Whether the attach succeeded, or not.</returns>
 public bool Attach(IEntity entity, IPlayerSession player, bool force = false)
 {
     return(Attach(entity, player, false, out _));
 }