public Husk(ActorInitializer init, HuskInfo info) { this.info = info; self = init.Self; TopLeft = init.GetValue <LocationInit, CPos>(); CenterPosition = init.GetValue <CenterPositionInit, WPos>(init.World.Map.CenterOfCell(TopLeft)); Facing = init.GetValue <FacingInit, WAngle>(info.GetInitialFacing()); dragSpeed = init.GetValue <HuskSpeedInit, int>(0); finalPosition = init.World.Map.CenterOfCell(TopLeft); effectiveOwner = init.GetValue <EffectiveOwnerInit, Player>(info, self.Owner); }
public ConyardChronoReturn(ActorInitializer init, ConyardChronoReturnInfo info) { this.info = info; self = init.Self; health = self.Trait <Health>(); wsb = self.TraitsImplementing <WithSpriteBody>().Single(w => w.Info.Name == info.Body); faction = init.GetValue <FactionInit, string>(self.Owner.Faction.InternalName); var returnInit = init.GetOrDefault <ChronoshiftReturnInit>(); if (returnInit != null) { returnTicks = returnInit.Ticks; duration = returnInit.Duration; origin = returnInit.Origin; // Defer to the end of tick as the lazy value may reference an actor that hasn't been created yet if (returnInit.Chronosphere != null) { init.World.AddFrameEndTask(w => chronosphere = returnInit.Chronosphere.Actor(init.World).Value); } } }
public BodyOrientation(ActorInitializer init, BodyOrientationInfo info) { this.info = info; var self = init.Self; var faction = init.GetValue <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)); }); }
public ProduceActorPower(ActorInitializer init, ProduceActorPowerInfo info) : base(init.Self, info) { faction = init.GetValue <FactionInit, string>(init.Self.Owner.Faction.InternalName); autoFire = info.AutoFire; key = info.AllowMultiple ? info.OrderName + "_" + init.Self.ActorID : info.OrderName; }
public TDGunboat(ActorInitializer init, TDGunboatInfo info) { Info = info; self = init.Self; var locationInit = init.GetOrDefault <LocationInit>(); if (locationInit != null) { SetPosition(self, locationInit.Value); } var centerPositionInit = init.GetOrDefault <CenterPositionInit>(); if (centerPositionInit != null) { SetPosition(self, centerPositionInit.Value); } Facing = init.GetValue <FacingInit, WAngle>(Info.GetInitialFacing()); // Prevent mappers from setting bogus facings if (Facing != Left && Facing != Right) { Facing = Facing.Angle > 511 ? Right : Left; } }
public GrantConditionOnDeploy(ActorInitializer init, GrantConditionOnDeployInfo info) : base(info) { self = init.Self; checkTerrainType = info.AllowedTerrainTypes.Count > 0; deployState = init.GetValue <DeployStateInit, DeployState>(DeployState.Undeployed); }
public Transforms(ActorInitializer init, TransformsInfo info) : base(info) { self = init.Self; actorInfo = self.World.Map.Rules.Actors[info.IntoActor]; buildingInfo = actorInfo.TraitInfoOrDefault <BuildingInfo>(); faction = init.GetValue <FactionInit, string>(self.Owner.Faction.InternalName); }
public HeliGrantConditionOnDeploy(ActorInitializer init, HeliGrantConditionOnDeployInfo info) : base(info) { self = init.Self; checkTerrainType = info.AllowedTerrainTypes.Count > 0; canTurn = self.Info.HasTraitInfo <IFacingInfo>(); deployState = init.GetValue <DeployStateInit, DeployState>(DeployState.Undeployed); }
public GainsExperience(ActorInitializer init, GainsExperienceInfo info) { self = init.Self; this.info = info; MaxLevel = info.Conditions.Count; initialExperience = init.GetValue <ExperienceInit, int>(info, 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; var subCellInit = init.GetOrDefault <SubCellInit>(); if (subCellInit != null) { FromSubCell = ToSubCell = subCellInit.Value; returnToCellOnCreationRecalculateSubCell = false; } var locationInit = init.GetOrDefault <LocationInit>(); if (locationInit != null) { fromCell = toCell = locationInit.Value; SetVisualPosition(self, init.World.Map.CenterOfSubCell(FromCell, FromSubCell)); } Facing = oldFacing = WAngle.FromFacing(init.GetValue <FacingInit, int>(info.InitialFacing)); // Sets the initial visual position // Unit will move into the cell grid (defined by LocationInit) as its initial activity var centerPositionInit = init.GetOrDefault <CenterPositionInit>(); if (centerPositionInit != null) { oldPos = centerPositionInit.Value; SetVisualPosition(self, oldPos); returnToCellOnCreation = true; } creationActivityDelay = init.GetValue <CreationActivityDelayInit, int>(0); }
public Pluggable(ActorInitializer init, PluggableInfo info) { Info = info; initialPlug = init.GetValue <PlugInit, string>(info, null); var plugsInit = init.GetValue <PlugsInit, Dictionary <CVec, string> >(new Dictionary <CVec, string>()); if (plugsInit.ContainsKey(Info.Offset)) { initialPlug = plugsInit[Info.Offset]; } if (info.Requirements.Count > 0) { plugTypesAvailability = new Dictionary <string, bool>(); foreach (var plug in info.Requirements) { plugTypesAvailability[plug.Key] = true; } } }
public ProvidesPrerequisite(ActorInitializer init, ProvidesPrerequisiteInfo info) : base(info) { prerequisite = info.Prerequisite; if (string.IsNullOrEmpty(prerequisite)) { prerequisite = init.Self.Info.Name; } faction = init.GetValue <FactionInit, string>(init.Self.Owner.Faction.InternalName); }
public ProductionQueue(ActorInitializer init, Actor playerActor, ProductionQueueInfo info) { self = init.Self; Info = info; Faction = init.GetValue <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); }
public AutoTarget(ActorInitializer init, AutoTargetInfo info) : base(info) { var self = init.Self; ActiveAttackBases = self.TraitsImplementing<AttackBase>().ToArray().Where(Exts.IsTraitEnabled); stance = init.GetValue<StanceInit, UnitStance>(self.Owner.IsBot || !self.Owner.Playable ? info.InitialStanceAI : info.InitialStance); PredictedStance = stance; allowMovement = Info.AllowMovement && self.TraitOrDefault<IMove>() != null; }
public Pluggable(ActorInitializer init, PluggableInfo info) { Info = info; initialPlug = init.GetValue <PlugInit, string>(info, null); if (info.Requirements.Count > 0) { plugTypesAvailability = new Dictionary <string, bool>(); foreach (var plug in info.Requirements) { plugTypesAvailability[plug.Key] = true; } } }
public Immobile(ActorInitializer init, ImmobileInfo info) { location = init.GetValue <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]; } }
public Building(ActorInitializer init, BuildingInfo info) { self = init.Self; topLeft = init.GetValue <LocationInit, CPos>(); Info = info; influence = self.World.WorldActor.Trait <BuildingInfluence>(); occupiedCells = Info.OccupiedTiles(TopLeft) .Select(c => Pair.New(c, SubCell.FullCell)).ToArray(); targetableCells = Info.FootprintTiles(TopLeft, FootprintCellType.Occupied) .Select(c => Pair.New(c, SubCell.FullCell)).ToArray(); transitOnlyCells = Info.TransitOnlyTiles(TopLeft).ToArray(); CenterPosition = init.World.Map.CenterOfCell(topLeft) + Info.CenterOffset(init.World); }
public InfiltrateForTransform(ActorInitializer init, InfiltrateForTransformInfo info) { this.info = info; faction = init.GetValue <FactionInit, string>(init.Self.Owner.Faction.InternalName); }
public Production(ActorInitializer init, ProductionInfo info) : base(info) { this.info = info; Faction = init.GetValue <FactionInit, string>(init.Self.Owner.Faction.InternalName); }
public GrantConditionOnLineBuildDirection(ActorInitializer init, GrantConditionOnLineBuildDirectionInfo info) { this.info = info; direction = init.GetValue <LineBuildDirectionInit, LineBuildDirection>(); }
public CrashLanding(ActorInitializer init, CrashLandingInfo info) { this.info = info; effectiveOwner = init.GetValue <EffectiveOwnerInit, Player>(info, init.Self.Owner); }
public FreeActor(ActorInitializer init, FreeActorInfo info) : base(info) { allowSpawn = init.GetValue <FreeActorInit, bool>(info, true); }
public TransformOnCondition(ActorInitializer init, TransformOnConditionInfo info) : base(info) { this.info = info; faction = init.GetValue <FactionInit, string>(info, init.Self.Owner.Faction.InternalName); }
public SpawnScrapOnDeath(ActorInitializer init, SpawnScrapOnDeathInfo info) : base(info) { enabled = init.Self.World.WorldActor.Trait <ScrapOptions>().Enabled; faction = init.GetValue <FactionInit, string>(info, init.Self.Owner.Faction.InternalName); }
public FallsToEarth(ActorInitializer init, FallsToEarthInfo info) { this.info = info; effectiveOwner = init.GetValue <EffectiveOwnerInit, Player>(info, init.Self.Owner); }
public GrantConditionOnFaction(ActorInitializer init, GrantConditionOnFactionInfo info) : base(info) { faction = init.GetValue <FactionInit, string>(init.Self.Owner.Faction.InternalName); }
public ProduceActorPower(ActorInitializer init, ProduceActorPowerInfo info) : base(init.Self, info) { faction = init.GetValue <FactionInit, string>(init.Self.Owner.Faction.InternalName); }
public TransformCrusherOnCrush(ActorInitializer init, TransformCrusherOnCrushInfo info) { this.info = info; faction = init.GetValue <FactionInit, string>(init.Self.Owner.Faction.InternalName); }
public SpawnActorOnDeath(ActorInitializer init, SpawnActorOnDeathInfo info) : base(info) { enabled = !info.RequiresLobbyCreeps || init.Self.World.WorldActor.Trait <MapCreeps>().Enabled; faction = init.GetValue <FactionInit, string>(init.Self.Owner.Faction.InternalName); }
public RenderSprites(ActorInitializer init, RenderSpritesInfo info) { Info = info; faction = init.GetValue <FactionInit, string>(init.Self.Owner.Faction.InternalName); }