Update() public méthode

public Update ( ) : void
Résultat void
Exemple #1
0
        void ActorAdded(Actor a)
        {
            if (a.Owner != Self.Owner)
            {
                return;
            }

            foreach (var t in a.TraitsImplementing <SupportPower>())
            {
                var key = MakeKey(t);

                if (!Powers.ContainsKey(key))
                {
                    Powers.Add(key, t.CreateInstance(key, this));

                    if (t.Info.Prerequisites.Any())
                    {
                        TechTree.Add(key, t.Info.Prerequisites, 0, this);
                        TechTree.Update();
                    }
                }

                Powers[key].Instances.Add(t);
            }
        }
        void ActorAdded(Actor a)
        {
            if (a.Owner != Self.Owner)
            {
                return;
            }

            foreach (var t in a.TraitsImplementing <SupportPower>())
            {
                var key = MakeKey(t);

                if (!Powers.ContainsKey(key))
                {
                    Powers.Add(key, new SupportPowerInstance(key, this)
                    {
                        Instances     = new List <SupportPower>(),
                        RemainingTime = t.Info.StartFullyCharged ? 0 : t.Info.ChargeTime * 25,
                        TotalTime     = t.Info.ChargeTime * 25,
                    });

                    if (t.Info.Prerequisites.Any())
                    {
                        TechTree.Add(key, t.Info.Prerequisites, 0, this);
                        TechTree.Update();
                    }
                }

                Powers[key].Instances.Add(t);
            }
        }
        void ActorAdded(Actor a)
        {
            if (a.Owner != Self.Owner)
            {
                return;
            }

            foreach (var t in a.TraitsImplementing <SupportPower>())
            {
                var key = MakeKey(t);

                var hasKey = Powers.ContainsKey(key);
                if (!hasKey)
                {
                    Powers.Add(key, t.CreateInstance(key, this));
                }

                Powers[key].Instances.Add(t);

                if (!hasKey)
                {
                    foreach (var prerequisite in t.Info.Prerequisites)
                    {
                        var techKey = key + prerequisite.Key;
                        TechTree.Add(techKey, prerequisite.Value, 0, this);
                    }

                    TechTree.Update();
                }
            }
        }
Exemple #4
0
        void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
        {
            ClearQueue();

            playerPower     = newOwner.PlayerActor.TraitOrDefault <PowerManager>();
            playerResources = newOwner.PlayerActor.Trait <PlayerResources>();
            developerMode   = newOwner.PlayerActor.Trait <DeveloperMode>();
            techTree        = newOwner.PlayerActor.Trait <TechTree>();

            if (!Info.Sticky)
            {
                Faction        = self.Owner.Faction.InternalName;
                IsValidFaction = !Info.Factions.Any() || Info.Factions.Contains(Faction);
            }

            // Regenerate the producibles and tech tree state
            oldOwner.PlayerActor.Trait <TechTree>().Remove(this);
            CacheProducibles(newOwner.PlayerActor);
            techTree.Update();
        }