Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
                }
            }
        }
Ejemplo n.º 3
0
        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));
            });
        }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
        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);
 }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 9
0
        public GainsExperience(ActorInitializer init, GainsExperienceInfo info)
        {
            self      = init.Self;
            this.info = info;

            MaxLevel          = info.Conditions.Count;
            initialExperience = init.GetValue <ExperienceInit, int>(info, 0);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
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;
                }
            }
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
		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;
		}
Ejemplo n.º 15
0
        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;
                }
            }
        }
Ejemplo n.º 16
0
        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];
            }
        }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
0
 public InfiltrateForTransform(ActorInitializer init, InfiltrateForTransformInfo info)
 {
     this.info = info;
     faction   = init.GetValue <FactionInit, string>(init.Self.Owner.Faction.InternalName);
 }
Ejemplo n.º 19
0
 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>();
 }
Ejemplo n.º 21
0
 public CrashLanding(ActorInitializer init, CrashLandingInfo info)
 {
     this.info      = info;
     effectiveOwner = init.GetValue <EffectiveOwnerInit, Player>(info, init.Self.Owner);
 }
Ejemplo n.º 22
0
 public FreeActor(ActorInitializer init, FreeActorInfo info)
     : base(info)
 {
     allowSpawn = init.GetValue <FreeActorInit, bool>(info, true);
 }
Ejemplo n.º 23
0
 public TransformOnCondition(ActorInitializer init, TransformOnConditionInfo info)
     : base(info)
 {
     this.info = info;
     faction   = init.GetValue <FactionInit, string>(info, init.Self.Owner.Faction.InternalName);
 }
Ejemplo n.º 24
0
 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);
 }
Ejemplo n.º 25
0
 public FallsToEarth(ActorInitializer init, FallsToEarthInfo info)
 {
     this.info      = info;
     effectiveOwner = init.GetValue <EffectiveOwnerInit, Player>(info, init.Self.Owner);
 }
Ejemplo n.º 26
0
 public GrantConditionOnFaction(ActorInitializer init, GrantConditionOnFactionInfo info)
     : base(info)
 {
     faction = init.GetValue <FactionInit, string>(init.Self.Owner.Faction.InternalName);
 }
Ejemplo n.º 27
0
 public ProduceActorPower(ActorInitializer init, ProduceActorPowerInfo info)
     : base(init.Self, info)
 {
     faction = init.GetValue <FactionInit, string>(init.Self.Owner.Faction.InternalName);
 }
Ejemplo n.º 28
0
 public TransformCrusherOnCrush(ActorInitializer init, TransformCrusherOnCrushInfo info)
 {
     this.info = info;
     faction   = init.GetValue <FactionInit, string>(init.Self.Owner.Faction.InternalName);
 }
Ejemplo n.º 29
0
 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);
 }
Ejemplo n.º 30
0
 public RenderSprites(ActorInitializer init, RenderSpritesInfo info)
 {
     Info    = info;
     faction = init.GetValue <FactionInit, string>(init.Self.Owner.Faction.InternalName);
 }