当前位置: 首页>>代码示例>>C#>>正文


C# Actor.Dispose方法代码示例

本文整理汇总了C#中Actor.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Actor.Dispose方法的具体用法?C# Actor.Dispose怎么用?C# Actor.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Actor的用法示例。


在下文中一共展示了Actor.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Tick

        public override Activity Tick(Actor self)
        {
            if (self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length <= 0)
            {
                if (info.ExplosionWeapon != null)
                {
                    // Use .FromPos since this actor is killed. Cannot use Target.FromActor
                    info.ExplosionWeapon.Impact(Target.FromPos(self.CenterPosition), self, Enumerable.Empty<int>());
                }

                self.Dispose();
                return null;
            }

            if (info.Spins)
            {
                spin += acceleration;
                aircraft.Facing = (aircraft.Facing + spin) % 256;
            }

            var move = info.Moves ? aircraft.FlyStep(aircraft.Facing) : WVec.Zero;
            move -= new WVec(WDist.Zero, WDist.Zero, info.Velocity);
            aircraft.SetPosition(self, aircraft.CenterPosition + move);

            return this;
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:26,代码来源:FallToEarth.cs

示例2: OnInside

		protected override void OnInside(Actor self)
		{
			if (health.DamageState == DamageState.Undamaged)
				return;
			target.InflictDamage(self, -health.MaxHP, null);
			self.Dispose();
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:7,代码来源:RepairBuilding.cs

示例3: OnInside

		protected override void OnInside(Actor self)
		{
			if (hut.BridgeDamageState == DamageState.Undamaged || hut.Repairing || hut.Bridge.GetHut(0) == null || hut.Bridge.GetHut(1) == null)
				return;
			hut.Repair(self);
			self.Dispose();
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:7,代码来源:RepairBridge.cs

示例4: OnInside

		protected override void OnInside(Actor self)
		{
			self.World.AddFrameEndTask(w =>
			{
				if (target.IsDead)
					return;

				if (cloak != null && cloak.Info.UncloakOnDemolish)
					cloak.Uncloak();

				for (var f = 0; f < flashes; f++)
					w.Add(new DelayedAction(flashesDelay + f * flashInterval, () =>
						w.Add(new FlashTarget(target, ticks: flashDuration))));

				w.Add(new DelayedAction(delay, () =>
				{
					if (target.IsDead)
						return;

					var modifiers = target.TraitsImplementing<IDamageModifier>()
						.Concat(self.Owner.PlayerActor.TraitsImplementing<IDamageModifier>())
						.Select(t => t.GetDamageModifier(self, null));

					if (Util.ApplyPercentageModifiers(100, modifiers) > 0)
						demolishables.Do(d => d.Demolish(target, self));
				}));

				if (enterBehaviour == EnterBehaviour.Suicide)
					self.Kill(self);
				else if (enterBehaviour == EnterBehaviour.Dispose)
					self.Dispose();
			});
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:33,代码来源:Demolish.cs

示例5: Tick

        public override Activity Tick(Actor self)
        {
            if (IsCanceled)
                return NextActivity;

            self.World.AddFrameEndTask(w =>
            {
                if (self.IsDead)
                    return;

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

                var selected = w.Selection.Contains(self);
                var controlgroup = w.Selection.GetControlGroupForActor(self);

                self.Dispose();
                foreach (var s in Sounds)
                    Game.Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);

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

                var init = new TypeDictionary
                {
                    new LocationInit(self.Location + Offset),
                    new OwnerInit(self.Owner),
                    new FacingInit(Facing),
                };

                if (SkipMakeAnims)
                    init.Add(new SkipMakeAnimsInit());

                if (Faction != null)
                    init.Add(new FactionInit(Faction));

                var health = self.TraitOrDefault<Health>();
                if (health != null)
                {
                    var newHP = ForceHealthPercentage > 0 ? ForceHealthPercentage : (health.HP * 100) / health.MaxHP;
                    init.Add(new HealthInit(newHP));
                }

                var cargo = self.TraitOrDefault<Cargo>();
                if (cargo != null)
                    init.Add(new RuntimeCargoInit(cargo.Passengers.ToArray()));

                var a = w.CreateActor(ToActor, init);
                foreach (var nt in self.TraitsImplementing<INotifyTransform>())
                    nt.AfterTransform(a);

                if (selected)
                    w.Selection.Add(w, a);
                if (controlgroup.HasValue)
                    w.Selection.AddToControlGroup(a, controlgroup.Value);
            });

            return this;
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:58,代码来源:Transform.cs

示例6: Tick

		public override Activity Tick(Actor self)
		{
			if (target.Type != TargetType.Actor)
				return NextActivity;

			if (IsCanceled || !self.IsInWorld || self.IsDead || !target.IsValidFor(self))
			{
				if (capturable.CaptureInProgress)
					capturable.EndCapture();

				return NextActivity;
			}

			var nearest = target.Actor.OccupiesSpace.NearestCellTo(mobile.ToCell);

			if ((nearest - mobile.ToCell).LengthSquared > 2)
				return Util.SequenceActivities(new MoveAdjacentTo(self, target), this);

			if (!capturable.CaptureInProgress)
				capturable.BeginCapture(self);
			else
			{
				if (capturable.Captor != self) return NextActivity;

				if (capturable.CaptureProgressTime % 25 == 0)
				{
					self.World.Add(new FlashTarget(target.Actor, self.Owner));
					self.World.Add(new FlashTarget(self));
				}

				if (capturable.CaptureProgressTime == capturable.Info.CaptureCompleteTime * 25)
				{
					self.World.AddFrameEndTask(w =>
					{
						if (target.Actor.IsDead)
							return;

						var oldOwner = target.Actor.Owner;

						target.Actor.ChangeOwner(self.Owner);

						foreach (var t in target.Actor.TraitsImplementing<INotifyCapture>())
							t.OnCapture(target.Actor, self, oldOwner, self.Owner);

						capturable.EndCapture();

						if (capturesInfo != null && capturesInfo.ConsumeActor)
							self.Dispose();
					});
				}
			}

			return this;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:54,代码来源:ExternalCaptureActor.cs

示例7: OnInside

		protected override void OnInside(Actor self)
		{
			if (target.IsDead)
				return;

			target.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(payload);
			self.Dispose();

			if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
				self.World.AddFrameEndTask(w => w.Add(new FloatingText(target.CenterPosition, target.Owner.Color.RGB, FloatingText.FormatCashTick(payload), 30)));
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:11,代码来源:DonateSupplies.cs

示例8: OnInside

        protected override void OnInside(Actor self)
        {
            if (target.IsDead || target.Owner == self.Owner)
                return;

            if (cloak != null && cloak.Info.UncloakOnInfiltrate)
                cloak.Uncloak();

            foreach (var t in target.TraitsImplementing<INotifyInfiltrated>())
                t.Infiltrated(target, self);

            self.Dispose();

            if (target.HasTrait<Building>())
                Sound.PlayToPlayer(self.Owner, "bldginf1.aud");
        }
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:16,代码来源:Infiltrate.cs

示例9: Tick

        public override Activity Tick(Actor self)
        {
            var cost = self.GetSellValue();

            var refund = (cost * sellableInfo.RefundPercent * (health == null ? 1 : health.HP)) / (100 * (health == null ? 1 : health.MaxHP));
            playerResources.GiveCash(refund);

            foreach (var ns in self.TraitsImplementing<INotifySold>())
                ns.Sold(self);

            if (refund > 0 && self.Owner.IsAlliedWith(self.World.RenderPlayer))
                self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.Owner.Color.RGB, FloatingText.FormatCashTick(refund), 30)));

            self.Dispose();
            return this;
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:16,代码来源:Sell.cs

示例10: OnInside

		protected override void OnInside(Actor self)
		{
			if (target.IsDead)
				return;

			var stance = self.Owner.Stances[target.Owner];
			if (!infiltrates.Info.ValidStances.HasStance(stance))
				return;

			if (cloak != null && cloak.Info.UncloakOnInfiltrate)
				cloak.Uncloak();

			foreach (var t in target.TraitsImplementing<INotifyInfiltrated>())
				t.Infiltrated(target, self);

			self.Dispose();

			if (target.Info.HasTraitInfo<BuildingInfo>())
				Game.Sound.PlayToPlayer(self.Owner, "bldginf1.aud");
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:20,代码来源:Infiltrate.cs

示例11: OnInside

        protected override void OnInside(Actor self)
        {
            if (actor.IsDead || capturable.BeingCaptured)
                return;

            if (building != null && !building.Lock())
                return;

            self.World.AddFrameEndTask(w =>
            {
                if (building != null && building.Locked)
                    building.Unlock();

                if (actor.IsDead || capturable.BeingCaptured)
                    return;

                var lowEnoughHealth = health.HP <= capturable.Info.CaptureThreshold * health.MaxHP;
                if (!capturesInfo.Sabotage || lowEnoughHealth || actor.Owner.NonCombatant)
                {
                    var oldOwner = actor.Owner;

                    actor.ChangeOwner(self.Owner);

                    foreach (var t in actor.TraitsImplementing<INotifyCapture>())
                        t.OnCapture(actor, self, oldOwner, self.Owner);

                    if (building != null && building.Locked)
                        building.Unlock();
                }
                else
                {
                    var damage = (int)(health.MaxHP * capturesInfo.SabotageHPRemoval);
                    actor.InflictDamage(self, damage, null);
                }

                self.Dispose();
            });
        }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:38,代码来源:CaptureActor.cs

示例12: Tick

        public override Activity Tick(Actor self)
        {
            switch (stance)
            {
                case AttackState.Uninitialized:
                    GrantUpgrades(self);
                    stance = AttackState.Burrowed;
                    countdown = swallow.Info.AttackDelay;
                    burrowLocation = self.Location;
                    break;
                case AttackState.Burrowed:
                    if (--countdown > 0)
                        return this;

                    var targetLocation = target.Actor.Location;

                    // The target has moved too far away
                    if ((burrowLocation - targetLocation).Length > NearEnough)
                    {
                        RevokeUpgrades(self);
                        return NextActivity;
                    }

                    // The target reached solid ground
                    if (!positionable.CanEnterCell(targetLocation, null, false))
                    {
                        RevokeUpgrades(self);
                        return NextActivity;
                    }

                    var targets = self.World.ActorMap.GetActorsAt(targetLocation)
                        .Where(t => !t.Equals(self) && weapon.IsValidAgainst(t, self));

                    if (!targets.Any())
                    {
                        RevokeUpgrades(self);
                        return NextActivity;
                    }

                    stance = AttackState.Attacking;
                    countdown = swallow.Info.ReturnDelay;
                    sandworm.IsAttacking = true;
                    AttackTargets(self, targets);

                    break;
                case AttackState.Attacking:
                    if (--countdown > 0)
                        return this;

                    sandworm.IsAttacking = false;

                    // There is a chance that the worm would just go away after attacking
                    if (self.World.SharedRandom.Next(100) <= sandworm.Info.ChanceToDisappear)
                    {
                        self.CancelActivity();
                        self.World.AddFrameEndTask(w => self.Dispose());
                    }

                    RevokeUpgrades(self);
                    return NextActivity;
            }

            return this;
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:64,代码来源:SwallowActor.cs

示例13: FindAndTransitionToNextState

        State FindAndTransitionToNextState(Actor self)
        {
            switch (nextState)
            {
                case State.ApproachingOrEntering:

                    // Reserve to enter or approach
                    isEnteringOrInside = false;
                    switch (TryReserveElseTryAlternateReserve(self))
                    {
                        case ReserveStatus.None:
                            return State.Done; // No available target -> abort to next activity
                        case ReserveStatus.TooFar:
                            inner = move.MoveToTarget(self, targetCenter ? Target.FromPos(target.CenterPosition) : target); // Approach
                            return State.ApproachingOrEntering;
                        case ReserveStatus.Pending:
                            return State.ApproachingOrEntering; // Retry next tick
                        case ReserveStatus.Ready:
                            break; // Reserved target -> start entering target
                    }

                    // Entering
                    isEnteringOrInside = true;
                    savedPos = self.CenterPosition; // Save position of self, before entering, for returning on exit

                    inner = move.MoveIntoTarget(self, target); // Enter

                    if (inner != null)
                    {
                        nextState = State.Inside; // Should be inside once inner activity is null
                        return State.ApproachingOrEntering;
                    }

                    // Can enter but there is no activity for it, so go inside without one
                    goto case State.Inside;

                case State.Inside:
                    // Might as well teleport into target if there is no MoveIntoTarget activity
                    if (nextState == State.ApproachingOrEntering)
                        nextState = State.Inside;

                    // Otherwise, try to recover from moving target
                    else if (target.CenterPosition != self.CenterPosition)
                    {
                        nextState = State.ApproachingOrEntering;
                        Unreserve(self, false);
                        if (Reserve(self) == ReserveStatus.Ready)
                        {
                            inner = move.MoveIntoTarget(self, target); // Enter
                            if (inner != null)
                                return State.ApproachingOrEntering;

                            nextState = State.ApproachingOrEntering;
                            goto case State.ApproachingOrEntering;
                        }

                        nextState = State.ApproachingOrEntering;
                        isEnteringOrInside = false;
                        inner = move.MoveIntoWorld(self, self.World.Map.CellContaining(savedPos));

                        return State.ApproachingOrEntering;
                    }

                    OnInside(self);

                    if (enterBehaviour == EnterBehaviour.Suicide)
                        self.Kill(self);
                    else if (enterBehaviour == EnterBehaviour.Dispose)
                        self.Dispose();

                    // Return if Abort(Actor) or Done(self) was called from OnInside.
                    if (nextState >= State.Exiting)
                        return State.Inside;

                    inner = this; // Start inside activity
                    nextState = State.Exiting; // Exit once inner activity is null (unless Done(self) is called)
                    return State.Inside;

                // TODO: Handle target moved while inside or always call done for movable targets and use a separate exit activity
                case State.Exiting:
                    inner = move.MoveIntoWorld(self, self.World.Map.CellContaining(savedPos));

                    // If not successfully exiting, retry on next tick
                    if (inner == null)
                        return State.Exiting;
                    isEnteringOrInside = false;
                    nextState = State.Done;
                    return State.Exiting;

                case State.Done:
                    return State.Done;
            }

            return State.Done; // dummy to quiet dumb compiler
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:95,代码来源:Enter.cs

示例14: Tick

		public override Activity Tick(Actor self)
		{
			if (IsCanceled) return NextActivity;
			self.Dispose();
			return null;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:6,代码来源:RemoveSelf.cs

示例15: OnInside

        protected override void OnInside(Actor self)
        {
            if (actor.IsDead || capturable.BeingCaptured)
                return;

            if (building != null && !building.Lock())
                return;

            self.World.AddFrameEndTask(w =>
            {
                if (building != null && building.Locked)
                    building.Unlock();

                if (actor.IsDead || capturable.BeingCaptured)
                    return;

                var lowEnoughHealth = health.HP <= capturable.Info.CaptureThreshold * health.MaxHP / 100;
                if (!capturesInfo.Sabotage || lowEnoughHealth || actor.Owner.NonCombatant)
                {
                    var oldOwner = actor.Owner;

                    actor.ChangeOwner(self.Owner);

                    foreach (var t in actor.TraitsImplementing<INotifyCapture>())
                        t.OnCapture(actor, self, oldOwner, self.Owner);

                    if (building != null && building.Locked)
                        building.Unlock();

                    if (self.Owner.Stances[oldOwner].HasStance(capturesInfo.PlayerExperienceStances))
                    {
                        var exp = self.Owner.PlayerActor.TraitOrDefault<PlayerExperience>();
                        if (exp != null)
                            exp.GiveExperience(capturesInfo.PlayerExperience);
                    }
                }
                else
                {
                    var damage = health.MaxHP * capturesInfo.SabotageHPRemoval / 100;
                    actor.InflictDamage(self, new Damage(damage));
                }

                self.Dispose();
            });
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:45,代码来源:CaptureActor.cs


注:本文中的Actor.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。