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);
        }
        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;
     }
 }
 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);
 }
 public NativeUserActions(IPlayerSession session, ICommandSender bus, IPlayerReadModel playerReadModel)
 {
     _session = session;
     _bus = bus;
     _playerReadModel = playerReadModel;
 }
Example #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));
        }
Example #8
0
 private void UpdateSurgeryUIBodyPartSlotRequest(IPlayerSession session, Dictionary <string, int> options)
 {
     UserInterface?.SendMessage(new RequestBodyPartSlotSurgeryUIMessage(options), session);
 }
Example #9
0
 //Called by SendMap() after sending everything.
 public virtual void SpawnPlayer(IPlayerSession player)
 {
     //This should be handled differently!!!.
     IoCManager.Resolve<IPlayerManager>().SpawnPlayerMob(player);
 }
Example #10
0
 public bool CanScript(IPlayerSession session)
 {
     return(Implementation?.CanScript(session) ?? false);
 }
Example #11
0
 public ViewSubscriberRemovedEvent(EntityUid view, IPlayerSession subscriber)
 {
     View       = view;
     Subscriber = subscriber;
 }
Example #12
0
 public bool CanScript(IPlayerSession session)
 {
     return(IsLocal(session));
 }
Example #13
0
 public bool CanCommand(IPlayerSession session, string cmdName)
 {
     return(Implementation?.CanCommand(session, cmdName) ?? false);
 }
Example #14
0
 public bool CanCommand(IPlayerSession session, string cmdName)
 {
     return(IsLocal(session));
 }
Example #15
0
 public bool CanViewVar(IPlayerSession session)
 {
     return(IsLocal(session));
 }
Example #16
0
 private static string FormatPlayerString(IPlayerSession session)
 {
     return(session != null ? $"{session.Name}" : "[HOST]");
 }
        public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
        {
            var ticker = IoCManager.Resolve <IGameTicker>();

            ticker.RestartRound();
        }
Example #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);
            }
        }
Example #19
0
 public AdminReg(IPlayerSession session, AdminData data)
 {
     Data    = data;
     Session = session;
 }
Example #20
0
 public bool CanAdminMenu(IPlayerSession session)
 {
     return(IsLocal(session));
 }
Example #21
0
 private void UpdatePlayerStatus(IPlayerSession session)
 {
     UserInterface?.SendMessage(new BlockGameMessages.BlockGameUserStatusMessage(_player == session), session);
 }
Example #22
0
 public bool CanAdminReloadPrototypes(IPlayerSession session)
 {
     return(IsLocal(session));
 }
Example #23
0
 public bool CanViewVar(IPlayerSession session)
 {
     return(Implementation?.CanViewVar(session) ?? false);
 }
 public void OpenUserInterface(IPlayerSession session)
 {
     UserInterface?.Open(session);
 }
Example #25
0
 public bool CanAdminMenu(IPlayerSession session)
 {
     return(Implementation?.CanAdminMenu(session) ?? false);
 }
Example #26
0
 public ServerBoundUserInterfaceMessage(BoundUserInterfaceMessage message, IPlayerSession session)
 {
     Message = message;
     Session = session;
 }
Example #27
0
 private void OpenSurgeryUI(IPlayerSession session)
 {
     UserInterface?.Open(session);
 }
Example #28
0
 internal void SendToSession(IPlayerSession session, BoundUserInterfaceMessage message, object uiKey)
 {
     SendNetworkMessage(new BoundInterfaceMessageWrapMessage(message, uiKey), session.ConnectedClient);
 }
Example #29
0
 private void CloseSurgeryUI(IPlayerSession session)
 {
     UserInterface?.Close(session);
 }
Example #30
0
 public PlayerDetachedEvent(IEntity entity, IPlayerSession player)
 {
     Entity    = entity;
     EntityUid = entity.Uid;
     Player    = player;
 }
Example #31
0
 public void SpawnPlayer(IPlayerSession player)
 {
     if (!_ready) return;
     CurrentGameMode.SpawnPlayer(player);
     CurrentGameMode.PlayerJoined(player);
 }
Example #32
0
 public virtual void PlayerJoined(IPlayerSession player)
 {
 }
Example #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);
 }
Example #34
0
 public AttachPlayerEvent(EntityUid uid, IPlayerSession player, bool force = false)
 {
     Uid    = uid;
     Player = player;
     Force  = force;
 }
Example #35
0
 private void OnPlayerStatusChanged(IPlayerSession session, SessionStatus oldStatus, SessionStatus newStatus)
 {
     PlayerStatusChanged?.Invoke(this, new SessionStatusEventArgs(session, oldStatus, newStatus));
 }
Example #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 _));
 }
Example #37
0
 public virtual void SpawnPlayer(IPlayerSession player) //Called by SendMap() after sending everything.
 {
     //This should be handled differently!!!.
     IoCManager.Resolve<IPlayerManager>().SpawnPlayerMob(player);
 }
Example #38
0
 public SessionStatusEventArgs(IPlayerSession session, SessionStatus oldStatus, SessionStatus newStatus)
 {
     Session   = session;
     OldStatus = oldStatus;
     NewStatus = newStatus;
 }
Example #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);
 }
Example #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 _));
 }