public bool OnGhostAttempt(Mind.Mind mind, bool canReturnGlobal)
        {
            var handleEv = new GhostAttemptHandleEvent(mind, canReturnGlobal);

            RaiseLocalEvent(handleEv);

            // Something else has handled the ghost attempt for us! We return its result.
            if (handleEv.Handled)
            {
                return(handleEv.Result);
            }

            var playerEntity = mind.CurrentEntity;

            var entities = IoCManager.Resolve <IEntityManager>();

            if (entities.HasComponent <GhostComponent>(playerEntity))
            {
                return(false);
            }

            if (mind.VisitingEntity != default)
            {
                mind.UnVisit();
            }

            var   position = playerEntity is { Valid : true }
        public override IObjectiveCondition GetAssigned(Mind.Mind mind)
        {
            var entityMgr = IoCManager.Resolve <IEntityManager>();
            var allHumans = entityMgr.EntityQuery <MindComponent>(true).Where(mc =>
            {
                var entity = mc.Mind?.OwnedEntity;

                if (entity == default)
                {
                    return(false);
                }

                return(entityMgr.TryGetComponent(entity, out MobStateComponent? mobState) &&
                       mobState.IsAlive() &&
                       mc.Mind != mind);
            }).Select(mc => mc.Mind).ToList();

            if (allHumans.Count == 0)
            {
                return(new DieCondition()); // I guess I'll die
            }
            return(new KillRandomPersonCondition {
                Target = IoCManager.Resolve <IRobustRandom>().Pick(allHumans)
            });
        }
Beispiel #3
0
        public void Execute(IConsoleShell shell, string argStr, string[] args)
        {
            if (args.Length != 2)
            {
                shell.WriteLine(Loc.GetString("shell-wrong-arguments-number"));
                return;
            }

            if (!int.TryParse(args[0], out var entityUid))
            {
                shell.WriteLine(Loc.GetString("shell-entity-uid-must-be-number"));
                return;
            }

            var entityManager = IoCManager.Resolve <IEntityManager>();

            var eUid = new EntityUid(entityUid);

            if (!eUid.IsValid() || !entityManager.EntityExists(eUid))
            {
                shell.WriteLine(Loc.GetString("shell-invalid-entity-id"));
                return;
            }

            var target = entityManager.GetEntity(eUid);

            if (!target.HasComponent <MindComponent>())
            {
                shell.WriteLine(Loc.GetString("set-mind-command-target-has-no-mind-message"));
                return;
            }

            if (!IoCManager.Resolve <IPlayerManager>().TryGetSessionByUsername(args[1], out var session))
            {
                shell.WriteLine(Loc.GetString("shell-target-player-does-not-exist"));
                return;
            }

            // hm, does player have a mind? if not we may need to give them one
            var playerCData = session.ContentData();

            if (playerCData == null)
            {
                shell.WriteLine(Loc.GetString("set-mind-command-target-has-no-content-data-message"));
                return;
            }

            var mind = playerCData.Mind;

            if (mind == null)
            {
                mind = new Mind.Mind(session.UserId)
                {
                    CharacterName = target.Name
                };
                playerCData.Mind = mind;
            }
            mind.TransferTo(target);
        }
 public IObjectiveCondition GetAssigned(Mind.Mind mind)
 {
     return(new StealCondition
     {
         _mind = mind,
         _prototypeId = _prototypeId,
         _amount = _amount
     });
 }
        public override IObjectiveCondition GetAssigned(Mind.Mind mind)
        {
            var entityMgr = IoCManager.Resolve <IEntityManager>();
            var allHumans = entityMgr.EntityQuery <MindComponent>(true).Where(mc =>
            {
                var entity = mc.Mind?.OwnedEntity;
                return((entity?.GetComponentOrNull <IMobStateComponent>()?.IsAlive() ?? false) && mc.Mind != mind);
            }).Select(mc => mc.Mind).ToList();

            return(new KillRandomPersonCondition {
                Target = IoCManager.Resolve <IRobustRandom>().Pick(allHumans)
            });
        }
Beispiel #6
0
        public IObjectiveCondition GetAssigned(Mind.Mind mind)
        {
            var entityMgr = IoCManager.Resolve <IEntityManager>();
            var traitors  = EntitySystem.Get <TraitorRuleSystem>().Traitors;

            if (traitors.Count == 0)
            {
                return new RandomTraitorAliveCondition {
                           _target = mind
                }
            }
            ;                                                                                   //You were made a traitor by admins, and are the first/only.
            return(new RandomTraitorAliveCondition {
                _target = IoCManager.Resolve <IRobustRandom>().Pick(traitors).Mind
            });
        }
        public IObjectiveCondition GetAssigned(Mind.Mind mind)
        {
            var entityMgr        = IoCManager.Resolve <IEntityManager>();
            var allOtherTraitors = new List <Mind.Mind>();

            foreach (var targetMind in entityMgr.EntityQuery <MindComponent>())
            {
                if (targetMind.Mind?.CharacterDeadIC == false && targetMind.Mind != mind && targetMind.Mind?.HasRole <TraitorRole>() == true)
                {
                    allOtherTraitors.Add(targetMind.Mind);
                }
            }

            return(new RandomTraitorAliveCondition {
                _target = IoCManager.Resolve <IRobustRandom>().Pick(allOtherTraitors)
            });
        }
Beispiel #8
0
        public ObjectivePrototype?GetRandomObjective(Mind.Mind mind)
        {
            var objectives = GetAllPossibleObjectives(mind).ToList();

            _random.Shuffle(objectives);

            //to prevent endless loops
            foreach (var objective in objectives)
            {
                if (!_random.Prob(objective.Probability))
                {
                    continue;
                }
                return(objective);
            }

            return(null);
        }
Beispiel #9
0
 public Job(Mind.Mind mind, JobPrototype jobPrototype) : base(mind)
 {
     Prototype  = jobPrototype;
     Name       = jobPrototype.LocalizedName;
     CanBeAntag = jobPrototype.CanBeAntag;
 }
Beispiel #10
0
 public AcceptCloningEui(Mind.Mind mind)
 {
     _mind = mind;
 }
Beispiel #11
0
 public bool CanBeAssigned(Mind.Mind mind)
 {
     return(EntitySystem.Get <TraitorRuleSystem>().TotalTraitors >= _requiredTraitors);
 }
 public abstract IObjectiveCondition GetAssigned(Mind.Mind mind);
Beispiel #13
0
 protected SuspicionRole(Mind.Mind mind) : base(mind)
 {
 }
 public ClonerDNAEntry(Mind.Mind m, HumanoidCharacterProfile hcp)
 {
     Mind    = m;
     Profile = hcp;
 }
 public SuspicionInnocentRole(Mind.Mind mind, AntagPrototype antagPrototype) : base(mind)
 {
     Prototype  = antagPrototype;
     Name       = antagPrototype.Name;
     Antagonist = antagPrototype.Antagonist;
 }
 public IObjectiveCondition GetAssigned(Mind.Mind mind)
 {
     return(new StayAliveCondition {
         _mind = mind
     });
 }
 public TraitorRole(Mind.Mind mind) : base(mind)
 {
 }
Beispiel #18
0
 public Job(Mind.Mind mind, JobPrototype jobPrototype) : base(mind)
 {
     Prototype = jobPrototype;
     Name      = jobPrototype.Name;
 }
 public bool CanBeAssigned(Mind.Mind mind)
 {
     return(mind.HasRole <TraitorRole>());
 }
Beispiel #20
0
 protected Role(Mind.Mind mind)
 {
     Mind = mind;
 }
Beispiel #21
0
 public GhostRoleMarkerRole(Mind.Mind mind, string name) : base(mind)
 {
     _name = name;
 }
Beispiel #22
0
 public IEnumerable <ObjectivePrototype> GetAllPossibleObjectives(Mind.Mind mind)
 {
     return(_prototypeManager.EnumeratePrototypes <ObjectivePrototype>().Where(objectivePrototype => objectivePrototype.CanBeAssigned(mind)));
 }
 public TraitorRole(Mind.Mind mind, AntagPrototype antagPrototype) : base(mind)
 {
     Prototype  = antagPrototype;
     Name       = antagPrototype.Name;
     Antagonist = antagPrototype.Antagonist;
 }
Beispiel #24
0
 public ObserverRole(Mind.Mind mind) : base(mind)
 {
 }