예제 #1
0
        public ClassicProductionQueueProperties(ScriptContext context, Player player)
            : base(context, player)
        {
            productionHandlers = new Dictionary <string, Action <Actor, Actor> >();

            queues = new Dictionary <string, ClassicProductionQueue>();
            foreach (var q in player.PlayerActor.TraitsImplementing <ClassicProductionQueue>().Where(q => q.Enabled))
            {
                queues.Add(q.Info.Type, q);
            }

            Action <Actor, Actor> globalProductionHandler = (factory, unit) =>
            {
                if (factory.Owner != player)
                {
                    return;
                }

                var queue = GetBuildableInfo(unit.Info.Name).Queue.First();

                if (productionHandlers.ContainsKey(queue))
                {
                    productionHandlers[queue](factory, unit);
                }
            };

            var triggers = TriggerGlobal.GetScriptTriggers(player.PlayerActor);

            triggers.OnOtherProducedInternal += globalProductionHandler;
        }
예제 #2
0
 public ProductionQueueProperties(ScriptContext context, Actor self)
     : base(context, self)
 {
     queues   = self.TraitsImplementing <ProductionQueue>().Where(q => q.Enabled).ToList();
     triggers = TriggerGlobal.GetScriptTriggers(self);
 }