Ejemplo n.º 1
0
        public Aircraft( ActorInitializer init , AircraftInfo info)
        {
            if (init.Contains<LocationInit>())
                this.Location = init.Get<LocationInit,int2>();

            this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : info.InitialFacing;
            this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit,int>() : 0;
            Info = info;
        }
Ejemplo n.º 2
0
        public static int GetInitialTurretFacing(ActorInitializer init, int def)
        {
            if (init.Contains<TurretFacingInit>())
                return init.Get<TurretFacingInit,int>();

            if (init.Contains<FacingInit>())
                return init.Get<FacingInit,int>();

            return def;
        }
Ejemplo n.º 3
0
        public Aircraft( ActorInitializer init , AircraftInfo info)
        {
            this.self = init.self;
            if( init.Contains<LocationInit>() )
                this.SubPxPosition = 1024 * Util.CenterOfCell( init.Get<LocationInit, int2>() );

            this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : info.InitialFacing;
            this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit,int>() : 0;
            Info = info;
        }
Ejemplo n.º 4
0
 public Turreted(ActorInitializer init, TurretedInfo info)
 {
     this.info = info;
     turretFacing = info.InitialFacing;
     turretFacing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : info.InitialFacing;
     facing = init.self.TraitOrDefault<IFacing>();
 }
Ejemplo n.º 5
0
 public Transforms(ActorInitializer init, TransformsInfo info)
 {
     self = init.Self;
     this.info = info;
     buildingInfo = self.World.Map.Rules.Actors[info.IntoActor].TraitInfoOrDefault<BuildingInfo>();
     faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : self.Owner.Faction.InternalName;
 }
Ejemplo n.º 6
0
        public Mobile(ActorInitializer init, MobileInfo info)
        {
            this.self = init.self;
            this.Info = info;

            uim = self.World.WorldActor.Trait<UnitInfluence>();

            if (init.Contains<LocationInit>())
            {
                this.__fromCell = this.__toCell = init.Get<LocationInit, int2>();
                this.PxPosition = Util.CenterOfCell(fromCell);
            }

            this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : info.InitialFacing;
            this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit, int>() : 0;
        }
Ejemplo n.º 7
0
        public BodyOrientation(ActorInitializer init, BodyOrientationInfo info)
        {
            this.info = info;
            var self = init.Self;
            var faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : self.Owner.Faction.InternalName;

            quantizedFacings = Exts.Lazy(() =>
            {
                // Override value is set
                if (info.QuantizedFacings >= 0)
                    return info.QuantizedFacings;

                var qboi = self.Info.TraitInfoOrDefault<IQuantizeBodyOrientationInfo>();

                // If a sprite actor has neither custom QuantizedFacings nor a trait implementing IQuantizeBodyOrientationInfo, throw
                if (qboi == null)
                {
                    if (self.Info.HasTraitInfo<WithSpriteBodyInfo>())
                        throw new InvalidOperationException("Actor '" + self.Info.Name + "' has a sprite body but no facing quantization."
                            + " Either add the QuantizeFacingsFromSequence trait or set custom QuantizedFacings on BodyOrientation.");
                    else
                        throw new InvalidOperationException("Actor type '" + self.Info.Name + "' does not define a quantized body orientation.");
                }

                return qboi.QuantizedBodyFacings(self.Info, self.World.Map.Rules.Sequences, faction);
            });
        }
Ejemplo n.º 8
0
		public Transforms(ActorInitializer init, TransformsInfo info)
		{
			self = init.self;
			this.info = info;
			bi = self.World.Map.Rules.Actors[info.IntoActor].Traits.GetOrDefault<BuildingInfo>();
			race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : self.Owner.Country.Race;
		}
Ejemplo n.º 9
0
 public AttackPopupTurreted(ActorInitializer init, AttackPopupTurretedInfo info)
     : base(init.self)
 {
     Info = info;
     buildComplete = init.Contains<SkipMakeAnimsInit>();
     turret = turrets.FirstOrDefault();
 }
Ejemplo n.º 10
0
Archivo: Husk.cs Proyecto: pdovy/OpenRA
 public Husk(ActorInitializer init)
 {
     this.self = init.self;
     this.location = init.Get<LocationInit,int2>();
     this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : 128;
     self.World.WorldActor.Trait<UnitInfluence>().Add(self, this);
 }
Ejemplo n.º 11
0
 public AttackPopupTurreted(ActorInitializer init, AttackPopupTurretedInfo info)
     : base(init.self)
 {
     Info = info;
     Turret = init.self.Trait<Turreted>();
     if (init.Contains<SkipMakeAnimsInit>())
         buildComplete = true;
 }
Ejemplo n.º 12
0
 public RenderBuilding( ActorInitializer init, Func<int> baseFacing )
     : base(init.self, baseFacing)
 {
     var self = init.self;
     if( init.Contains<SkipMakeAnimsInit>() || !self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation )
         anim.PlayThen( "idle", () => self.World.AddFrameEndTask( _ => Complete( self ) ) );
     else
         anim.PlayThen( "make", () => self.World.AddFrameEndTask( _ => Complete( self ) ) );
 }
Ejemplo n.º 13
0
        public Mobile(ActorInitializer init, MobileInfo info)
        {
            this.self = init.self;
            this.Info = info;

            toSubCell = fromSubCell = info.SharesCell ? SubCell.Center : SubCell.FullCell;
            if (init.Contains<SubCellInit>())
            {
                this.fromSubCell = this.toSubCell = init.Get<SubCellInit, SubCell>();
            }

            if (init.Contains<LocationInit>())
            {
                this.__fromCell = this.__toCell = init.Get<LocationInit, int2>();
                this.PxPosition = Util.CenterOfCell(fromCell) + info.SubCellOffsets[fromSubCell];
            }

            this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : info.InitialFacing;
            this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit, int>() : 0;
        }
Ejemplo n.º 14
0
        public ProvidesPrerequisite(ActorInitializer init, ProvidesPrerequisiteInfo info)
        {
            this.info = info;
            prerequisite = info.Prerequisite;

            if (string.IsNullOrEmpty(prerequisite))
                prerequisite = init.Self.Info.Name;

            var race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.Self.Owner.Country.Race;

            Update(init.Self.Owner, race);
        }
Ejemplo n.º 15
0
        public ProvidesPrerequisite(ActorInitializer init, ProvidesPrerequisiteInfo info)
        {
            this.info = info;
            prerequisite = info.Prerequisite;

            if (string.IsNullOrEmpty(prerequisite))
                prerequisite = init.Self.Info.Name;

            var faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;

            Update(init.Self.Owner, faction);
        }
Ejemplo n.º 16
0
 public AttackPopupTurreted(ActorInitializer init, AttackPopupTurretedInfo info)
     : base(init.self)
 {
     Info = info;
     Turret = init.self.Trait<Turreted>();
     if (init.Contains<SkipMakeAnimsInit>())
     {
         State = PopupState.Closed;
         init.self.Trait<RenderBuilding>()
             .PlayCustomAnimRepeating(init.self, "closed-idle");
         Turret.desiredFacing = null;
     }
 }
Ejemplo n.º 17
0
        public Mobile(ActorInitializer init, MobileInfo info)
        {
            this.self = init.self;
            this.Info = info;

            shroud = self.World.WorldActor.Trait<Shroud>();
            uim = self.World.WorldActor.Trait<UnitInfluence>();
            bim = self.World.WorldActor.Trait<BuildingInfluence>();
            canShareCell = self.HasTrait<SharesCell>();

            if (init.Contains<LocationInit>())
            {
                this.__fromCell = this.__toCell = init.Get<LocationInit,int2>();
                AddInfluence();
            }

            this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : info.InitialFacing;
            this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit,int>() : 0;

            TerrainCost = new Dictionary<string, float>();
            TerrainSpeed = new Dictionary<string, float>();

            if (info.TerrainTypes.Count() != info.TerrainSpeeds.Count())
                throw new InvalidOperationException("Mobile TerrainType/TerrainSpeed length mismatch");

            if (info.TerrainCostOverrides != null)
                for (int i = 0; i < info.TerrainCostOverrides.Count(); i++)
                {
                    TerrainCost.Add(info.TerrainCostOverrides[i], info.TerrainCosts[i]);
                }

            for (int i = 0; i < info.TerrainTypes.Count(); i++)
            {
                if (!TerrainCost.ContainsKey(info.TerrainTypes[i]))
                    TerrainCost.Add(info.TerrainTypes[i], 1f/info.TerrainSpeeds[i]);

                TerrainSpeed.Add(info.TerrainTypes[i], info.TerrainSpeeds[i]);
            }
        }
Ejemplo n.º 18
0
        public TDGunboat(ActorInitializer init, TDGunboatInfo info)
        {
            Info = info;
            self = init.Self;

            if (init.Contains <LocationInit>())
            {
                SetPosition(self, init.Get <LocationInit, CPos>());
            }

            if (init.Contains <CenterPositionInit>())
            {
                SetPosition(self, init.Get <CenterPositionInit, WPos>());
            }

            Facing = init.Contains <FacingInit>() ? init.Get <FacingInit, int>() : Info.GetInitialFacing();

            // Prevent mappers from setting bogus facings
            if (Facing != 64 && Facing != 192)
            {
                Facing = Facing > 127 ? 192 : 64;
            }
        }
Ejemplo n.º 19
0
        public FrozenUnderFog(ActorInitializer init, FrozenUnderFogInfo info)
        {
            // Spawned actors (e.g. building husks) shouldn't be revealed
            startsRevealed = info.StartsRevealed && !init.Contains <ParentActorInit>();
            var footprintCells = FootprintUtils.Tiles(init.Self).ToList();

            footprint       = footprintCells.Select(cell => cell.ToMPos(init.World.Map)).ToArray();
            footprintRegion = CellRegion.BoundingRegion(init.World.Map.TileShape, footprintCells);
            tooltip         = Exts.Lazy(() => init.Self.TraitsImplementing <IToolTip>().FirstOrDefault());
            health          = Exts.Lazy(() => init.Self.TraitOrDefault <Health>());

            frozen  = new Dictionary <Player, FrozenActor>();
            visible = init.World.Players.ToDictionary(p => p, p => false);
        }
Ejemplo n.º 20
0
        public RenderBuilding( ActorInitializer init, RenderBuildingInfo info, Func<int> baseFacing )
            : base(init.self, baseFacing)
        {
            Info = info;
            var self = init.self;
            // Work around a bogus crash
            anim.PlayRepeating( NormalizeSequence(self, "idle") );

            // Can't call Complete() directly from ctor because other traits haven't been inited yet
            if (self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation && !init.Contains<SkipMakeAnimsInit>())
                self.QueueActivity(new MakeAnimation(self, () => Complete(self)));
            else
                self.QueueActivity(new CallFunc(() => Complete(self)));
        }
Ejemplo n.º 21
0
        public Mobile(ActorInitializer init, MobileInfo info)
            : base(info)
        {
            self = init.Self;

            speedModifiers = Exts.Lazy(() => self.TraitsImplementing <ISpeedModifier>().ToArray().Select(x => x.GetSpeedModifier()));

            ToSubCell = FromSubCell = info.LocomotorInfo.SharesCell ? init.World.Map.Grid.DefaultSubCell : SubCell.FullCell;
            if (init.Contains <SubCellInit>())
            {
                FromSubCell = ToSubCell = init.Get <SubCellInit, SubCell>();

                returnToCellOnCreationRecalculateSubCell = false;
            }

            if (init.Contains <LocationInit>())
            {
                fromCell = toCell = init.Get <LocationInit, CPos>();
                SetVisualPosition(self, init.World.Map.CenterOfSubCell(FromCell, FromSubCell));
            }

            Facing = oldFacing = init.Contains <FacingInit>() ? init.Get <FacingInit, int>() : info.InitialFacing;

            // Sets the initial visual position
            // Unit will move into the cell grid (defined by LocationInit) as its initial activity
            if (init.Contains <CenterPositionInit>())
            {
                oldPos = init.Get <CenterPositionInit, WPos>();
                SetVisualPosition(self, oldPos);
                returnToCellOnCreation = true;
            }

            if (init.Contains <CreationActivityDelayInit>())
            {
                creationActivityDelay = init.Get <CreationActivityDelayInit, int>();
            }
        }
Ejemplo n.º 22
0
        public WithCrumbleOverlay(ActorInitializer init, WithCrumbleOverlayInfo info)
            : base(info)
        {
            this.info = info;

            if (init.Contains <SkipMakeAnimsInit>(info))
            {
                return;
            }

            renderSprites = init.Self.Trait <RenderSprites>();

            overlay   = new Animation(init.World, renderSprites.GetImage(init.Self));
            animation = new AnimationWithOffset(overlay, null, () => IsTraitDisabled);
        }
Ejemplo n.º 23
0
        public Aircraft(ActorInitializer init, AircraftInfo info)
        {
            this.info = info;
            this.self = init.self;

            if (init.Contains <LocationInit>())
            {
                SetPosition(self, init.Get <LocationInit, CPos>());
            }


            if (init.Contains <AltitudeInit>())
            {
                var z = init.Get <AltitudeInit, int>() * 1024 / Game.CellSize;
                SetPosition(self, CenterPosition + new WVec(0, 0, z - CenterPosition.Z));
            }

            if (init.Contains <CenterPositionInit>())
            {
                SetPosition(self, init.Get <CenterPositionInit, WPos>());
            }

            this.Facing = init.Contains <FacingInit>() ? init.Get <FacingInit, int>() : info.InitialFacing;
        }
Ejemplo n.º 24
0
        public Building(ActorInitializer init, BuildingInfo info)
        {
            self    = init.Self;
            topLeft = init.Get <LocationInit, CPos>();
            Info    = info;

            occupiedCells = Info.UnpathableTiles(TopLeft)
                            .Select(c => Pair.New(c, SubCell.FullCell)).ToArray();

            targetableCells = Info.FootprintTiles(TopLeft, FootprintCellType.Occupied)
                              .Select(c => Pair.New(c, SubCell.FullCell)).ToArray();

            CenterPosition    = init.World.Map.CenterOfCell(topLeft) + Info.CenterOffset(init.World);
            SkipMakeAnimation = init.Contains <SkipMakeAnimsInit>();
        }
Ejemplo n.º 25
0
        public ProductionQueue(ActorInitializer init, Actor playerActor, ProductionQueueInfo info)
        {
            self            = init.Self;
            Info            = info;
            playerResources = playerActor.Trait <PlayerResources>();
            developerMode   = playerActor.Trait <DeveloperMode>();

            Faction        = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : self.Owner.Faction.InternalName;
            IsValidFaction = !info.Factions.Any() || info.Factions.Contains(Faction);
            Enabled        = IsValidFaction;

            CacheProducibles(playerActor);
            allProducibles       = producible.Where(a => a.Value.Buildable || a.Value.Visible).Select(a => a.Key);
            buildableProducibles = producible.Where(a => a.Value.Buildable).Select(a => a.Key);
        }
Ejemplo n.º 26
0
        public FrozenUnderFog(ActorInitializer init, FrozenUnderFogInfo info)
        {
            this.info = info;

            var map = init.World.Map;

            // Spawned actors (e.g. building husks) shouldn't be revealed
            startsRevealed = info.StartsRevealed && !init.Contains <ParentActorInit>();
            var footprintCells = FootprintUtils.Tiles(init.Self).ToList();

            footprint = footprintCells.SelectMany(c => map.ProjectedCellsCovering(c.ToMPos(map))).ToArray();
            tooltip   = Exts.Lazy(() => init.Self.TraitsImplementing <IToolTip>().FirstOrDefault());
            health    = Exts.Lazy(() => init.Self.TraitOrDefault <Health>());

            frozen  = new Dictionary <Player, FrozenActor>();
            visible = init.World.Players.ToDictionary(p => p, p => false);
        }
Ejemplo n.º 27
0
        public WithCrumbleOverlay(ActorInitializer init, WithCrumbleOverlayInfo info)
        {
            if (init.Contains <SkipMakeAnimsInit>())
            {
                return;
            }

            var rs = init.Self.Trait <RenderSprites>();

            var overlay = new Animation(init.World, rs.GetImage(init.Self));
            var anim    = new AnimationWithOffset(overlay, null, () => !buildComplete);

            // Remove the animation once it is complete
            overlay.PlayThen(info.Sequence, () => init.World.AddFrameEndTask(w => rs.Remove(anim)));

            rs.Add(anim, info.Palette, info.IsPlayerPalette);
        }
Ejemplo n.º 28
0
        public AutoTarget(ActorInitializer init, AutoTargetInfo info)
            : base(info)
        {
            var self = init.Self;

            ActiveAttackBases = self.TraitsImplementing <AttackBase>().ToArray().Where(Exts.IsTraitEnabled);

            if (init.Contains <StanceInit>())
            {
                stance = init.Get <StanceInit, UnitStance>();
            }
            else
            {
                stance = self.Owner.IsBot || !self.Owner.Playable ? info.InitialStanceAI : info.InitialStance;
            }

            PredictedStance = stance;
        }
Ejemplo n.º 29
0
        public GainsExperience(ActorInitializer init, GainsExperienceInfo info)
        {
            self      = init.Self;
            this.info = info;

            MaxLevel = info.Conditions.Count;
            var cost = self.Info.TraitInfo <ValuedInfo>().Cost;

            foreach (var kv in info.Conditions)
            {
                nextLevel.Add(Pair.New(kv.Key * cost, kv.Value));
            }

            if (init.Contains <ExperienceInit>())
            {
                initialExperience = init.Get <ExperienceInit, int>();
            }
        }
Ejemplo n.º 30
0
        public FreeActor(ActorInitializer init, FreeActorInfo info)
        {
            if (init.Contains <FreeActorInit>() && !init.Get <FreeActorInit>().ActorValue)
            {
                return;
            }

            init.Self.World.AddFrameEndTask(w =>
            {
                w.CreateActor(info.Actor, new TypeDictionary
                {
                    new ParentActorInit(init.Self),
                    new LocationInit(init.Self.Location + info.SpawnOffset),
                    new OwnerInit(init.Self.Owner),
                    new FacingInit(info.Facing),
                });
            });
        }
Ejemplo n.º 31
0
        public AutoTarget(ActorInitializer init, AutoTargetInfo info)
        {
            var self = init.Self;

            this.info = info;
            attack    = self.Trait <AttackBase>();

            if (init.Contains <StanceInit>())
            {
                Stance = init.Get <StanceInit, UnitStance>();
            }
            else
            {
                Stance = self.Owner.IsBot || !self.Owner.Playable ? info.InitialStanceAI : info.InitialStance;
            }

            PredictedStance = Stance;
            at = self.TraitOrDefault <AttackFollow>();
        }
Ejemplo n.º 32
0
        public BodyOrientation(ActorInitializer init, BodyOrientationInfo info)
        {
            this.info = info;
            var self = init.Self;
            var race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : self.Owner.Faction.InternalName;

            quantizedFacings = Exts.Lazy(() =>
            {
                // Override value is set
                if (info.QuantizedFacings >= 0)
                    return info.QuantizedFacings;

                var qboi = self.Info.Traits.GetOrDefault<IQuantizeBodyOrientationInfo>();
                if (qboi == null)
                    throw new InvalidOperationException("Actor type '" + self.Info.Name + "' does not define a quantized body orientation.");

                return qboi.QuantizedBodyFacings(self.Info, self.World.Map.SequenceProvider, race);
            });
        }
Ejemplo n.º 33
0
        public RenderBuilding(ActorInitializer init, RenderBuildingInfo info, Func <int> baseFacing)
            : base(init.self, baseFacing)
        {
            var self = init.self;

            // Work around a bogus crash
            anim.PlayRepeating(NormalizeSequence(self, "idle"));
            self.Trait <IBodyOrientation>().SetAutodetectedFacings(anim.CurrentSequence.Facings);

            // Can't call Complete() directly from ctor because other traits haven't been inited yet
            if (self.Info.Traits.Get <RenderBuildingInfo>().HasMakeAnimation&& !init.Contains <SkipMakeAnimsInit>())
            {
                self.QueueActivity(new MakeAnimation(self, () => Complete(self)));
            }
            else
            {
                self.QueueActivity(new CallFunc(() => Complete(self)));
            }
        }
Ejemplo n.º 34
0
        public GainsExperience(ActorInitializer init, GainsExperienceInfo info)
        {
            self      = init.self;
            this.Info = info;
            var cost = self.Info.Traits.Get <ValuedInfo>().Cost;

            Levels   = Info.CostThreshold.Select(t => (int)(t * cost)).ToArray();
            RankAnim = new Animation("rank");
            RankAnim.PlayFetchIndex("rank", () => Level - 1);

            if (init.Contains <ExperienceInit>())
            {
                Experience = init.Get <ExperienceInit, int>();

                while (Level < Levels.Length && Experience >= Levels[Level])
                {
                    Level++;
                }
            }
        }
Ejemplo n.º 35
0
        public Pluggable(ActorInitializer init, PluggableInfo info)
        {
            Info = info;

            var plugInit = init.Contains <PlugsInit>() ? init.Get <PlugsInit, Dictionary <CVec, string> >() : new Dictionary <CVec, string>();

            if (plugInit.ContainsKey(Info.Offset))
            {
                initialPlug = plugInit[Info.Offset];
            }

            if (info.Requirements.Count > 0)
            {
                plugTypesAvailability = new Dictionary <string, bool>();
                foreach (var plug in info.Requirements)
                {
                    plugTypesAvailability[plug.Key] = true;
                }
            }
        }
Ejemplo n.º 36
0
        public SelfConstructing(ActorInitializer init, SelfConstructingInfo info)
            : base(init, info)
        {
            Info = info;
            wsb  = init.Self.Trait <WithSpriteBody>();

            if (!string.IsNullOrEmpty(Info.Condition) && token == Actor.InvalidConditionToken)
            {
                token = init.Self.GrantCondition(Info.Condition);
            }

            spawnType = init.Contains <PlaceBuildingInit>(null) ? SpawnType.PlaceBuilding : init.Contains <SpawnedByMapInit>() ? SpawnType.Other : SpawnType.Deploy;

            for (Steps = 0; ; Steps++)
            {
                if (!wsb.DefaultAnimation.HasSequence(Info.Sequence.Substring(0, Info.Sequence.Length - 1) + Steps))
                {
                    break;
                }
            }
        }
Ejemplo n.º 37
0
        public GainsExperience(ActorInitializer init, GainsExperienceInfo info)
        {
            self      = init.Self;
            this.info = info;

            MaxLevel = info.Upgrades.Count;

            var cost = self.Info.Traits.Get <ValuedInfo>().Cost;

            foreach (var kv in info.Upgrades)
            {
                nextLevel.Add(Pair.New(kv.Key * cost, kv.Value));
            }

            if (init.Contains <ExperienceInit>())
            {
                GiveExperience(init.Get <ExperienceInit, int>(), info.SuppressLevelupAnimation);
            }

            um = self.Trait <UpgradeManager>();
        }
Ejemplo n.º 38
0
        public WithMakeAnimation(ActorInitializer init, WithMakeAnimationInfo info)
        {
            this.info = info;
            var self = init.self;

            renderBuilding = self.Trait <RenderBuilding>();

            var building = self.Trait <Building>();

            if (!init.Contains <SkipMakeAnimsInit>())
            {
                renderBuilding.PlayCustomAnimThen(self, info.Sequence, () =>
                {
                    building.NotifyBuildingComplete(self);
                });
            }
            else
            {
                building.NotifyBuildingComplete(self);
            }
        }
Ejemplo n.º 39
0
        public FreeActor(ActorInitializer init, FreeActorInfo info)
        {
            if (init.Contains <FreeActorInit>() && !init.Get <FreeActorInit>().ActorValue)
            {
                return;
            }

            init.Self.World.AddFrameEndTask(w =>
            {
                var a = w.CreateActor(info.Actor, new TypeDictionary
                {
                    new ParentActorInit(init.Self),
                    new LocationInit(init.Self.Location + info.SpawnOffset),
                    new OwnerInit(init.Self.Owner),
                    new FacingInit(info.Facing),
                });

                if (info.InitialActivity != null)
                {
                    a.QueueActivity(Game.CreateObject <Activity>(info.InitialActivity));
                }
            });
        }
Ejemplo n.º 40
0
        public BodyOrientation(ActorInitializer init, BodyOrientationInfo info)
        {
            this.info = info;
            var self = init.Self;
            var race = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : self.Owner.Faction.InternalName;

            quantizedFacings = Exts.Lazy(() =>
            {
                // Override value is set
                if (info.QuantizedFacings >= 0)
                {
                    return(info.QuantizedFacings);
                }

                var qboi = self.Info.Traits.GetOrDefault <IQuantizeBodyOrientationInfo>();
                if (qboi == null)
                {
                    throw new InvalidOperationException("Actor type '" + self.Info.Name + "' does not define a quantized body orientation.");
                }

                return(qboi.QuantizedBodyFacings(self.Info, self.World.Map.SequenceProvider, race));
            });
        }
Ejemplo n.º 41
0
 public RenderSprites(ActorInitializer init, RenderSpritesInfo info)
 {
     this.info = info;
     race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.Self.Owner.Country.Race;
 }
Ejemplo n.º 42
0
        public LeavesHusk(ActorInitializer init, LeavesHuskInfo info)
        {
            this.info = info;

            race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.self.Owner.Country.Race;
        }
Ejemplo n.º 43
0
 public RenderSprites(ActorInitializer init, RenderSpritesInfo info)
 {
     this.info = info;
     race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.Self.Owner.Faction.InternalName;
 }
Ejemplo n.º 44
0
 public Production(ActorInitializer init, ProductionInfo info)
 {
     Info = info;
     rp = Exts.Lazy(() => init.Self.IsDead ? null : init.Self.TraitOrDefault<RallyPoint>());
     Faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
Ejemplo n.º 45
0
        public ProductionQueue(ActorInitializer init, Actor playerActor, ProductionQueueInfo info)
        {
            self = init.self;
            Info = info;
            playerResources = playerActor.Trait<PlayerResources>();
            playerPower = playerActor.Trait<PowerManager>();
            developerMode = playerActor.Trait<DeveloperMode>();

            Race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : self.Owner.Country.Race;
            Enabled = !info.Race.Any() || info.Race.Contains(Race);

            CacheProduceables(playerActor);
        }
Ejemplo n.º 46
0
		public ProduceActorPower(ActorInitializer init, ProduceActorPowerInfo info)
			: base(init.Self, info)
		{
			faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
		}
Ejemplo n.º 47
0
 public SpawnActorOnDeath(ActorInitializer init, SpawnActorOnDeathInfo info)
 {
     this.info = info;
     enabled = !info.RequiresLobbyCreeps || init.Self.World.WorldActor.Trait<MapCreeps>().Enabled;
     faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
Ejemplo n.º 48
0
 public FallsToEarth(ActorInitializer init, FallsToEarthInfo info)
 {
     init.Self.QueueActivity(false, new FallToEarth(init.Self, info));
     effectiveOwner = init.Contains <EffectiveOwnerInit>() ? init.Get <EffectiveOwnerInit, Player>() : init.Self.Owner;
 }
Ejemplo n.º 49
0
 public ProductionCA(ActorInitializer init, ProductionCAInfo info)
     : base(info)
 {
     rp      = Exts.Lazy(() => init.Self.IsDead ? null : init.Self.TraitOrDefault <RallyPoint>());
     Faction = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
Ejemplo n.º 50
0
 public TransformOnCapture(ActorInitializer init, TransformOnCaptureInfo info)
 {
     this.info = info;
     faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
Ejemplo n.º 51
0
 public Husk(ActorInitializer init)
 {
     this.location = init.Get<LocationInit,int2>();
     this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : 128;
 }
 public CreateActorOnDeath(ActorInitializer init, CreateActorOnDeathInfo info)
 {
     this.info = info;
     enabled   = !info.RequiresLobbyCreeps || init.Self.World.WorldActor.Trait <MapCreeps>().Enabled;
     faction   = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
Ejemplo n.º 53
0
        public ProductionQueue(ActorInitializer init, Actor playerActor, ProductionQueueInfo info)
        {
            self = init.Self;
            Info = info;
            playerResources = playerActor.Trait<PlayerResources>();
            playerPower = playerActor.Trait<PowerManager>();
            developerMode = playerActor.Trait<DeveloperMode>();

            Faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : self.Owner.Faction.InternalName;
            Enabled = !info.Factions.Any() || info.Factions.Contains(Faction);

            CacheProducibles(playerActor);
            allProducibles = producible.Where(a => a.Value.Buildable || a.Value.Visible).Select(a => a.Key);
            buildableProducibles = producible.Where(a => a.Value.Buildable).Select(a => a.Key);
        }
Ejemplo n.º 54
0
 public TransformOnCapture(ActorInitializer init, TransformOnCaptureInfo info)
 {
     this.info = info;
     faction   = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
Ejemplo n.º 55
0
 public ClonesProducedUnits(ActorInitializer init, ClonesProducedUnitsInfo info)
 {
     this.info  = info;
     production = init.Self.Trait <Production>();
     race       = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
Ejemplo n.º 56
0
 public ProduceActorPowerCA(ActorInitializer init, ProduceActorPowerCAInfo info)
     : base(init.Self, info)
 {
     faction = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
Ejemplo n.º 57
0
 public InfiltrateForTransform(ActorInitializer init, InfiltrateForTransformInfo info)
 {
     this.info = info;
     faction   = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
Ejemplo n.º 58
0
 public GrantConditionOnFaction(ActorInitializer init, GrantConditionOnFactionInfo info)
     : base(info)
 {
     faction = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
Ejemplo n.º 59
0
 public RenderSprites(ActorInitializer init, RenderSpritesInfo info)
 {
     Info    = info;
     faction = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
Ejemplo n.º 60
0
        public SpawnActorOnDeath(ActorInitializer init, SpawnActorOnDeathInfo info)
        {
            this.info = info;

            faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
        }