예제 #1
0
 public PhaseAction(PhaseToken token, Type modType, OnPhaseStartedHandler handler)
 {
     Phase    = token;
     ModType  = modType;
     _handler = handler;
     if (!typeof(ISoLModV1).IsAssignableFrom(modType))
     {
         throw new ArgumentException("Mod type is expected!");
     }
 }
예제 #2
0
        public PhaseToken AcquirePhase(string name)
        {
            var activated = _tokenGroups.FirstOrDefault(tg => tg.Item1.Name == name)?.Item1;

            if (activated == null)
            {
                activated = new PhaseToken(name);
                _tokenGroups.Add(new Tuple <PhaseToken, List <PhaseAction> >(activated, new List <PhaseAction>()));
            }

            return(activated);
        }
예제 #3
0
        public bool RunPhase(PhaseToken phase, AnankeContext context)
        {
            var group = _tokenGroups.FirstOrDefault(tg => tg.Item1 == phase);

            if (group == null)
            {
                return(false);
            }
            var actions = group.Item2;

            //TODO: Should have some sorting rules.
            foreach (var action in actions)
            {
                action.Do(context);
            }

            return(true);
        }