示例#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);
        }