Beispiel #1
0
 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);
 }
Beispiel #2
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;
        }
Beispiel #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;
        }
Beispiel #4
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;
        }
Beispiel #5
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;
		}
Beispiel #6
0
 public Building(ActorInitializer init)
 {
     this.self = init.self;
     this.topLeft = init.Get<LocationInit,int2>();
     this.Info = self.Info.Traits.Get<BuildingInfo>();
     this.PlayerPower = init.self.Owner.PlayerActor.Trait<PowerManager>();
 }
Beispiel #7
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>();
 }
Beispiel #8
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;
 }
Beispiel #9
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);
            });
        }
Beispiel #10
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;
        }
Beispiel #11
0
 public Building(ActorInitializer init)
 {
     this.self = init.self;
     this.topLeft = init.Get<LocationInit,int2>();
     Info = self.Info.Traits.Get<BuildingInfo>();
     self.CenterLocation = Game.CellSize
         * ((float2)topLeft + .5f * (float2)Info.Dimensions);
 }
Beispiel #12
0
        public Immobile(ActorInitializer init, ImmobileInfo info)
        {
            this.location = init.Get<LocationInit, CPos>();

            if (info.OccupiesSpace)
                occupied = new [] { Pair.New(TopLeft, SubCell.FullCell) };
            else
                occupied = new Pair<CPos, SubCell>[0];
        }
Beispiel #13
0
        public Crate(ActorInitializer init, CrateInfo info)
        {
            this.self = init.self;
            this.info = info;

            if (init.Contains <LocationInit>())
            {
                SetPosition(self, init.Get <LocationInit, CPos>());
            }
        }
Beispiel #14
0
        public Health(ActorInitializer init, HealthInfo info)
        {
            Info  = info;
            MaxHP = info.HP > 0 ? info.HP : 1;

            // Cast to long to avoid overflow when multiplying by the health
            hp = init.Contains <HealthInit>() ? (int)(init.Get <HealthInit, int>() * (long)MaxHP / 100) : MaxHP;

            DisplayHP = hp;
        }
Beispiel #15
0
        public Cargo(ActorInitializer init, CargoInfo info)
        {
            self             = init.Self;
            Info             = info;
            Unloading        = false;
            checkTerrainType = info.UnloadTerrainTypes.Count > 0;

            if (init.Contains <RuntimeCargoInit>())
            {
                cargo       = new Stack <Actor>(init.Get <RuntimeCargoInit, Actor[]>());
                totalWeight = cargo.Sum(c => GetWeight(c));
            }
            else if (init.Contains <CargoInit>())
            {
                foreach (var u in init.Get <CargoInit, string[]>())
                {
                    var unit = self.World.CreateActor(false, u.ToLowerInvariant(),
                                                      new TypeDictionary {
                        new OwnerInit(self.Owner)
                    });

                    cargo.Push(unit);
                }

                totalWeight = cargo.Sum(c => GetWeight(c));
            }
            else
            {
                foreach (var u in info.InitialUnits)
                {
                    var unit = self.World.CreateActor(false, u.ToLowerInvariant(),
                                                      new TypeDictionary {
                        new OwnerInit(self.Owner)
                    });

                    cargo.Push(unit);
                }

                totalWeight = cargo.Sum(c => GetWeight(c));
            }

            facing = Exts.Lazy(self.TraitOrDefault <IFacing>);
        }
Beispiel #16
0
        public ColonyBit(ActorInitializer init, ColonyBitInfo info)
        {
            this.info = info;

            var colonyBitInit = init.Get <ColonyBitInit>(info);

            colony = colonyBitInit.Value.Actor(init.World).Value.Trait <DefeatedColony>();

            lifetime = init.World.SharedRandom.Next(info.MinLifetime, info.MaxLifetime);
        }
Beispiel #17
0
 public Crate(ActorInitializer init, CrateInfo info)
 {
     this.self = init.self;
     if (init.Contains <LocationInit>())
     {
         this.Location = init.Get <LocationInit, int2>();
         PxPosition    = Util.CenterOfCell(Location);
     }
     this.Info = info;
 }
Beispiel #18
0
 public ScriptTags(ActorInitializer init, ScriptTagsInfo info)
 {
     if (init.Contains <ScriptTagsInit>())
     {
         foreach (var tag in init.Get <ScriptTagsInit, string[]>())
         {
             tags.Add(tag);
         }
     }
 }
Beispiel #19
0
        public Immobile(ActorInitializer init, ImmobileInfo info)
        {
            location = init.Get<LocationInit, CPos>();
            position = init.World.Map.CenterOfCell(location);

            if (info.OccupiesSpace)
                occupied = new[] { Pair.New(TopLeft, SubCell.FullCell) };
            else
                occupied = new Pair<CPos, SubCell>[0];
        }
Beispiel #20
0
 public GrantConditionOnDeploy(ActorInitializer init, GrantConditionOnDeployInfo info)
 {
     self             = init.Self;
     Info             = info;
     checkTerrainType = info.AllowedTerrainTypes.Count > 0;
     canTurn          = self.Info.HasTraitInfo <IFacingInfo>();
     if (init.Contains <DeployStateInit>())
     {
         deployState = init.Get <DeployStateInit, DeployState>();
     }
 }
Beispiel #21
0
        public Cargo(ActorInitializer init, CargoInfo info)
        {
            this.self = init.self;
            this.info = info;

            if (init.Contains <CargoInit>())
            {
                cargo       = init.Get <CargoInit, Actor[]>().ToList();
                totalWeight = cargo.Sum(c => GetWeight(c));
            }
        }
Beispiel #22
0
        public Building(ActorInitializer init, BuildingInfo info)
        {
            this.self        = init.self;
            this.topLeft     = init.Get <LocationInit, CPos>();
            this.Info        = info;
            this.PlayerPower = init.self.Owner.PlayerActor.Trait <PowerManager>();

            occupiedCells = FootprintUtils.UnpathableTiles(self.Info.Name, Info, TopLeft)
                            .Select(c => Pair.New(c, SubCell.FullCell)).ToArray();
            pxPosition = (PPos)((2 * topLeft.ToInt2() + Info.Dimensions) * Game.CellSize / 2);
        }
Beispiel #23
0
        public ProvidesPrerequisite(ActorInitializer init, ProvidesPrerequisiteInfo info) : base(info)
        {
            prerequisite = info.Prerequisite;

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

            faction = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : init.Self.Owner.Faction.InternalName;
        }
Beispiel #24
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, CPos>();
                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;
        }
        public Chronoshiftable(ActorInitializer init, ChronoshiftableInfo info)
        {
            this.info = info;
            self      = init.Self;

            if (init.Contains <ChronoshiftReturnInit>())
            {
                ReturnTicks = init.Get <ChronoshiftReturnInit, int>();
            }

            if (init.Contains <ChronoshiftOriginInit>())
            {
                Origin = init.Get <ChronoshiftOriginInit, CPos>();
            }

            if (init.Contains <ChronoshiftChronosphereInit>())
            {
                chronosphere = init.Get <ChronoshiftChronosphereInit, Actor>();
            }
        }
Beispiel #26
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];
            }
        }
Beispiel #27
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;
        }
Beispiel #28
0
        public LegacyBridgeHut(ActorInitializer init, LegacyBridgeHutInfo info)
        {
            var bridge = init.Get <ParentActorInit>().Value;

            init.World.AddFrameEndTask(_ =>
            {
                Bridge = bridge.Actor(init.World).Value.Trait <Bridge>();
                Bridge.AddHut(this);
                FirstBridge = Bridge.Enumerate(0, true).Last();
            });
        }
Beispiel #29
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);
        }
Beispiel #30
0
        public Building(ActorInitializer init, BuildingInfo info)
        {
            this.self        = init.self;
            this.topLeft     = init.Get <LocationInit, CPos>();
            this.Info        = info;
            this.PlayerPower = init.self.Owner.PlayerActor.Trait <PowerManager>();

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

            CenterPosition = topLeft.CenterPosition + FootprintUtils.CenterOffset(Info);
        }
Beispiel #31
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);
        }
Beispiel #32
0
        public GainsExperience(ActorInitializer init, GainsExperienceInfo info)
        {
            self      = init.Self;
            this.info = info;

            MaxLevel = info.Conditions.Count;

            if (init.Contains <ExperienceInit>())
            {
                initialExperience = init.Get <ExperienceInit, int>();
            }
        }
Beispiel #33
0
 public GrantConditionOnDeploy(ActorInitializer init, GrantConditionOnDeployInfo info)
 {
     self             = init.Self;
     this.info        = info;
     checkTerrainType = info.AllowedTerrainTypes.Count > 0;
     canTurn          = self.Info.HasTraitInfo <IFacingInfo>();
     body             = Exts.Lazy(self.TraitOrDefault <WithSpriteBody>);
     if (init.Contains <DeployStateInit>())
     {
         deployState = init.Get <DeployStateInit, DeployState>();
     }
 }
Beispiel #34
0
        public Aircraft(ActorInitializer init, AircraftInfo 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.InitialFacing;

            // TODO: HACK: This is a hack until we can properly distinquish between airplane and helicopter!
            // Or until the activities get unified enough so that it doesn't matter.
            IsPlane = !info.CanHover;
        }
Beispiel #35
0
        public Building(ActorInitializer init, BuildingInfo info)
        {
            this.self    = init.Self;
            this.topLeft = init.Get <LocationInit, CPos>();
            this.Info    = info;

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

            CenterPosition    = init.World.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(init.World, Info);
            SkipMakeAnimation = init.Contains <SkipMakeAnimsInit>();
        }
Beispiel #36
0
        public ProductionQueue(ActorInitializer init, Actor playerActor, ProductionQueueInfo info)
        {
            self = init.Self;
            Info = info;

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

            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);
        }
Beispiel #37
0
        public Cargo(ActorInitializer init, CargoInfo info)
        {
            self      = init.self;
            Info      = info;
            Unloading = false;

            if (init.Contains <RuntimeCargoInit>())
            {
                cargo       = init.Get <RuntimeCargoInit, Actor[]>().ToList();
                totalWeight = cargo.Sum(c => GetWeight(c));
            }
            else if (init.Contains <CargoInit>())
            {
                foreach (var u in init.Get <CargoInit, string[]>())
                {
                    var unit = self.World.CreateActor(false, u.ToLowerInvariant(),
                                                      new TypeDictionary {
                        new OwnerInit(self.Owner)
                    });

                    cargo.Add(unit);
                }

                totalWeight = cargo.Sum(c => GetWeight(c));
            }
            else
            {
                foreach (var u in info.InitialUnits)
                {
                    var unit = self.World.CreateActor(false, u.ToLowerInvariant(),
                                                      new TypeDictionary {
                        new OwnerInit(self.Owner)
                    });

                    cargo.Add(unit);
                }

                totalWeight = cargo.Sum(c => GetWeight(c));
            }
        }
Beispiel #38
0
        public Asteroid(ActorInitializer init, AsteroidInfo info)
        {
            Info = info;
            self = init.Self;

            if (init.Contains <LocationInit>())
            {
                SetPosition(self, init.Get <LocationInit, CPos>());
                StartLocation = init.Get <LocationInit, CPos>();
            }
            if (init.Contains <CenterPositionInit>())
            {
                SetPosition(self, init.Get <CenterPositionInit, WPos>());
            }
            if (init.Contains <LocationOfCrush>())
            {
                CrushLocation = init.Get <LocationOfCrush, CPos>();
            }

            if (init.Contains <LocationOfEnd>())
            {
                EndLocation = init.Get <LocationOfEnd, CPos>();
            }

            Facing       = init.Contains <FacingInit>() ? init.Get <FacingInit, int>() : Info.InitialFacing;
            LandAltitude = info.LandAltitude;
        }
Beispiel #39
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.Faction.InternalName;
            Enabled = !info.Race.Any() || info.Race.Contains(Race);

            CacheProduceables(playerActor);
        }
Beispiel #40
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();

            if (init.Contains <ExperienceInit>())
            {
                GiveExperience(init.Get <ExperienceInit, int>());
            }
        }
Beispiel #41
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]);
            }
        }
Beispiel #42
0
 public DeployToUpgrade(ActorInitializer init, DeployToUpgradeInfo info)
 {
     this.self        = init.Self;
     this.info        = info;
     manager          = self.Trait <UpgradeManager>();
     checkTerrainType = info.AllowedTerrainTypes.Count > 0;
     canTurn          = self.Info.HasTraitInfo <IFacingInfo>();
     body             = Exts.Lazy(self.TraitOrDefault <WithSpriteBody>);
     if (init.Contains <DeployStateInit>())
     {
         deployState = init.Get <DeployStateInit, DeployState>();
     }
 }
Beispiel #43
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);
        }
Beispiel #44
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;
            }
        }
Beispiel #45
0
        public Immobile(ActorInitializer init, ImmobileInfo info)
        {
            this.location = init.Get <LocationInit, CPos>();

            if (info.OccupiesSpace)
            {
                occupied = new [] { Pair.New(TopLeft, SubCell.FullCell) }
            }
            ;
            else
            {
                occupied = new Pair <CPos, SubCell> [0];
            }
        }
        public ProvidesAIPrerequisite(ActorInitializer init, ProvidesAIPrerequisiteInfo 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);
        }
Beispiel #47
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>();
            }
        }
        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);
            });
        }
Beispiel #49
0
 public RenderSprites(ActorInitializer init, RenderSpritesInfo info)
 {
     this.info = info;
     race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.Self.Owner.Country.Race;
 }
Beispiel #50
0
 public TransformOnCapture(ActorInitializer init, TransformOnCaptureInfo info)
 {
     this.info = info;
     faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
Beispiel #51
0
        public LeavesHusk(ActorInitializer init, LeavesHuskInfo info)
        {
            this.info = info;

            race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.self.Owner.Country.Race;
        }
Beispiel #52
0
 public Waypoint(ActorInitializer init)
 {
     this.location = init.Get<LocationInit, CPos>();
 }
Beispiel #53
0
 public RenderSprites(ActorInitializer init, RenderSpritesInfo info)
 {
     this.info = info;
     race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.Self.Owner.Faction.InternalName;
 }
Beispiel #54
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;
 }
Beispiel #55
0
 public BridgeHut(ActorInitializer init)
 {
     bridge = init.Get<ParentActorInit>().value.Trait<Bridge>();
 }
Beispiel #56
0
        public SpawnActorOnDeath(ActorInitializer init, SpawnActorOnDeathInfo info)
        {
            this.info = info;

            faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
        }
Beispiel #57
0
		public ProduceActorPower(ActorInitializer init, ProduceActorPowerInfo info)
			: base(init.Self, info)
		{
			faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
		}
Beispiel #58
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);
        }
Beispiel #59
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);
        }
Beispiel #60
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;
 }