Inheritance: OpenRA.Activities.Activity
Exemplo n.º 1
0
 public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
 {
     var facing = self.TraitOrDefault<IFacing>();
     var transform = new Transform(self, info.IntoActor) { ForceHealthPercentage = info.ForceHealthPercentage };
     if (facing != null) transform.Facing = facing.Facing;
     transform.SkipMakeAnims = info.SkipMakeAnims;
     self.CancelActivity();
     self.QueueActivity(transform);
 }
Exemplo n.º 2
0
		void MaybeTransform(Actor self, Actor passenger, string transformTo)
		{
			if (info.PassengerTypes.Contains(passenger.Info.Name) && transformTo != null)
			{
				self.World.AddFrameEndTask(w =>
				{
					var facing = self.TraitOrDefault<IFacing>();
					var transform = new Transform(self, transformTo) { SkipMakeAnims = info.SkipMakeAnims };
					if (facing != null) transform.Facing = facing.Facing;

					self.CancelActivity();
					self.QueueActivity(transform);
					if (info.BecomeNeutral) self.ChangeOwner(self.World.WorldActor.Owner);
				});
			}
		}
Exemplo n.º 3
0
        public void DeployTransform(bool queued)
        {
            var building = self.TraitOrDefault<Building>();
            if (!CanDeploy() || (building != null && !building.Lock()))
            {
                foreach (var s in info.NoTransformSounds)
                    Sound.PlayToPlayer(self.Owner, s);

                Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.NoTransformNotification, self.Owner.Faction.InternalName);

                return;
            }

            if (!queued)
                self.CancelActivity();

            if (self.HasTrait<IFacing>())
                self.QueueActivity(new Turn(self, info.Facing));

            foreach (var nt in self.TraitsImplementing<INotifyTransform>())
                nt.BeforeTransform(self);

            var transform = new Transform(self, info.IntoActor)
            {
                Offset = info.Offset,
                Facing = info.Facing,
                Sounds = info.TransformSounds,
                Notification = info.TransformNotification,
                Race = race
            };

            var makeAnimation = self.TraitOrDefault<WithMakeAnimation>();
            if (makeAnimation != null)
                makeAnimation.Reverse(self, transform);
            else
                self.QueueActivity(transform);
        }
Exemplo n.º 4
0
        public void DeployTransform(bool queued)
        {
            if (!queued && !CanDeploy())
            {
                // Only play the "Cannot deploy here" audio
                // for non-queued orders
                foreach (var s in info.NoTransformSounds)
                    Game.Sound.PlayToPlayer(SoundType.World, self.Owner, s);

                Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.NoTransformNotification, self.Owner.Faction.InternalName);

                return;
            }

            if (!queued)
                self.CancelActivity();

            if (self.Info.HasTraitInfo<IFacingInfo>())
                self.QueueActivity(new Turn(self, info.Facing));

            if (self.Info.HasTraitInfo<AircraftInfo>())
                self.QueueActivity(new HeliLand(self, true));

            self.QueueActivity(new CallFunc(() =>
            {
                // Prevent deployment in bogus locations
                var building = self.TraitOrDefault<Building>();
                if (!CanDeploy() || (building != null && !building.Lock()))
                    return;

                foreach (var nt in self.TraitsImplementing<INotifyTransform>())
                    nt.BeforeTransform(self);

                var transform = new Transform(self, info.IntoActor)
                {
                    Offset = info.Offset,
                    Facing = info.Facing,
                    Sounds = info.TransformSounds,
                    Notification = info.TransformNotification,
                    Faction = faction
                };

                var makeAnimation = self.TraitOrDefault<WithMakeAnimation>();
                if (makeAnimation != null)
                    makeAnimation.Reverse(self, transform);
                else
                    self.QueueActivity(transform);
            }));
        }