コード例 #1
0
ファイル: Transforms.cs プロジェクト: RobotCaleb/OpenRA
        public void DeployTransform(bool queued)
        {
            var b = self.TraitOrDefault<Building>();

            if (!CanDeploy() || (b != null && !b.Lock()))
            {
                foreach (var s in info.NoTransformSounds)
                    Sound.PlayToPlayer(self.Owner, s);

                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, Race = race };
            var makeAnimation = self.TraitOrDefault<WithMakeAnimation>();
            if (makeAnimation != null)
                makeAnimation.Reverse(self, transform);
            else
                self.QueueActivity(transform);
        }
コード例 #2
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);
 }
コード例 #3
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);
                });
            }
        }