示例#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;
        }
示例#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;
        }
示例#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;
        }
示例#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>();
 }
示例#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;
 }
示例#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;
        }
示例#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);
            });
        }
示例#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;
		}
示例#9
0
 public AttackPopupTurreted(ActorInitializer init, AttackPopupTurretedInfo info)
     : base(init.self)
 {
     Info = info;
     buildComplete = init.Contains<SkipMakeAnimsInit>();
     turret = turrets.FirstOrDefault();
 }
示例#10
0
文件: Husk.cs 项目: 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);
 }
示例#11
0
 public AttackPopupTurreted(ActorInitializer init, AttackPopupTurretedInfo info)
     : base(init.self)
 {
     Info = info;
     Turret = init.self.Trait<Turreted>();
     if (init.Contains<SkipMakeAnimsInit>())
         buildComplete = true;
 }
示例#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 ) ) );
 }
示例#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;
        }
示例#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);
        }
示例#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);
        }
示例#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;
     }
 }
示例#17
0
文件: Mobile.cs 项目: mgatland/OpenRA
        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]);
            }
        }
示例#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;
            }
        }
示例#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);
        }
示例#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)));
        }
示例#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>();
            }
        }
示例#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);
        }
示例#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;
        }
        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>();
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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;
        }
示例#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>();
            }
        }
示例#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),
                });
            });
        }
示例#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>();
        }
示例#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);
            });
        }
示例#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)));
            }
        }
示例#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++;
                }
            }
        }
示例#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;
                }
            }
        }
示例#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;
                }
            }
        }
示例#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>();
        }
示例#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);
            }
        }
示例#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));
                }
            });
        }
示例#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));
            });
        }
示例#41
0
 public RenderSprites(ActorInitializer init, RenderSpritesInfo info)
 {
     this.info = info;
     race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.Self.Owner.Country.Race;
 }
示例#42
0
        public LeavesHusk(ActorInitializer init, LeavesHuskInfo info)
        {
            this.info = info;

            race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.self.Owner.Country.Race;
        }
示例#43
0
 public RenderSprites(ActorInitializer init, RenderSpritesInfo info)
 {
     this.info = info;
     race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.Self.Owner.Faction.InternalName;
 }
示例#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;
 }
示例#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);
        }
示例#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;
		}
示例#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;
 }
示例#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;
 }
示例#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;
 }
示例#50
0
 public TransformOnCapture(ActorInitializer init, TransformOnCaptureInfo info)
 {
     this.info = info;
     faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
示例#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;
 }
示例#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);
        }
示例#54
0
 public TransformOnCapture(ActorInitializer init, TransformOnCaptureInfo info)
 {
     this.info = info;
     faction   = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
示例#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;
 }
 public ProduceActorPowerCA(ActorInitializer init, ProduceActorPowerCAInfo info)
     : base(init.Self, info)
 {
     faction = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
示例#57
0
 public InfiltrateForTransform(ActorInitializer init, InfiltrateForTransformInfo info)
 {
     this.info = info;
     faction   = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
示例#58
0
 public GrantConditionOnFaction(ActorInitializer init, GrantConditionOnFactionInfo info)
     : base(info)
 {
     faction = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
示例#59
0
 public RenderSprites(ActorInitializer init, RenderSpritesInfo info)
 {
     Info    = info;
     faction = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
示例#60
0
        public SpawnActorOnDeath(ActorInitializer init, SpawnActorOnDeathInfo info)
        {
            this.info = info;

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