public static NormalizeSequence ( OpenRA.Graphics.Animation anim, DamageState state, string sequence ) : string | ||
anim | OpenRA.Graphics.Animation | |
state | DamageState | |
sequence | string | |
리턴 | string |
void INotifyResupply.BeforeResupply(Actor self, Actor target, ResupplyType types) { repairing = types.HasFlag(ResupplyType.Repair); if (!repairing) { return; } if (Info.StartSequence != null) { visible = true; overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), Info.StartSequence), () => overlay.PlayRepeating(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), Info.Sequence))); } }
public WithProductionDoorOverlay(Actor self, WithProductionDoorOverlayInfo info) : base(info) { var renderSprites = self.Trait <RenderSprites>(); door = new Animation(self.World, renderSprites.GetImage(self)); door.PlayFetchDirection(RenderSprites.NormalizeSequence(door, self.GetDamageState(), info.Sequence), () => desiredFrame - door.CurrentFrame); var buildingInfo = self.Info.TraitInfo <BuildingInfo>(); var offset = buildingInfo.CenterOffset(self.World).Y + 512; renderSprites.Add(new AnimationWithOffset(door, null, () => IsTraitDisabled, offset)); }
public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { var facing = 0; var ifacing = init.Actor.TraitInfoOrDefault <IFacingInfo>(); if (ifacing != null) { facing = init.Contains <FacingInit>() ? init.Get <FacingInit, int>() : ifacing.GetInitialFacing(); } var anim = new Animation(init.World, image, () => facing); anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), StandSequences.First())); yield return(new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale)); }
public WithIdleRepairOverlay(Actor self, WithIdleRepairOverlayInfo info) : base(info) { var rs = self.Trait <RenderSprites>(); var body = self.Trait <BodyOrientation>(); overlay = new Animation(self.World, rs.GetImage(self), () => IsTraitPaused); overlay.PlayRepeating(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), Info.IdleSequence)); idling = true; var anim = new AnimationWithOffset(overlay, () => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))), () => IsTraitDisabled, p => RenderUtils.ZOffsetFromCenter(self, p, 1)); rs.Add(anim, info.Palette, info.IsPlayerPalette); }
public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, string image, int facings, PaletteReference p) { if (!EnabledByDefault) { yield break; } if (Palette != null) { var ownerName = init.Get <OwnerInit>().InternalName; p = init.WorldRenderer.Palette(IsPlayerPalette ? Palette + ownerName : Palette); } Func <WAngle> facing; var dynamicfacingInit = init.GetOrDefault <DynamicFacingInit>(); if (dynamicfacingInit != null) { facing = dynamicfacingInit.Value; } else { var f = init.GetValue <FacingInit, WAngle>(WAngle.Zero); facing = () => f; } var anim = new Animation(init.World, Image ?? image, facing) { IsDecoration = IsDecoration }; anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence)); var body = init.Actor.TraitInfo <BodyOrientationInfo>(); Func <WRot> orientation = () => body.QuantizeOrientation(WRot.FromYaw(facing()), facings); Func <WVec> offset = () => body.LocalToWorld(Offset.Rotate(orientation())); Func <int> zOffset = () => { var tmpOffset = offset(); return(tmpOffset.Y + tmpOffset.Z + 1); }; yield return(new SpriteActorPreview(anim, offset, zOffset, p)); }
public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { if (!EnabledByDefault) { yield break; } if (Palette != null) { p = init.WorldRenderer.Palette(Palette); } Func <WAngle> facing; var dynamicfacingInit = init.GetOrDefault <DynamicFacingInit>(); if (dynamicfacingInit != null) { var getFacing = dynamicfacingInit.Value; facing = () => WAngle.FromFacing(getFacing()); } else { var f = WAngle.FromFacing(init.GetValue <FacingInit, int>(0)); facing = () => f; } var anim = new Animation(init.World, image, facing); anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence)); var body = init.Actor.TraitInfo <BodyOrientationInfo>(); Func <WRot> orientation = () => body.QuantizeOrientation(WRot.FromYaw(facing()), facings); Func <WVec> offset = () => body.LocalToWorld(Offset.Rotate(orientation())); Func <int> zOffset = () => { var tmpOffset = offset(); return(tmpOffset.Y + tmpOffset.Z + 1); }; yield return(new SpriteActorPreview(anim, offset, zOffset, p, rs.Scale)); }
public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { if (!EnabledByDefault) { yield break; } var anim = new Animation(init.World, image, init.GetFacing()); anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), StandSequences.First())); if (IsPlayerPalette) { p = init.WorldRenderer.Palette(Palette + init.Get <OwnerInit>().InternalName); } else if (Palette != null) { p = init.WorldRenderer.Palette(Palette); } yield return(new SpriteActorPreview(anim, () => WVec.Zero, () => 0, p, rs.Scale)); }
public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { if (UpgradeMinEnabledLevel > 0) { yield break; } if (Palette != null) { p = init.WorldRenderer.Palette(Palette); } Func <int> facing; if (init.Contains <DynamicFacingInit>()) { facing = init.Get <DynamicFacingInit, Func <int> >(); } else { var f = init.Contains <FacingInit>() ? init.Get <FacingInit, int>() : 0; facing = () => f; } var anim = new Animation(init.World, image, facing); anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence)); var body = init.Actor.TraitInfo <BodyOrientationInfo>(); Func <WRot> orientation = () => body.QuantizeOrientation(WRot.FromFacing(facing()), facings); Func <WVec> offset = () => body.LocalToWorld(Offset.Rotate(orientation())); Func <int> zOffset = () => { var tmpOffset = offset(); return(tmpOffset.Y + tmpOffset.Z + 1); }; yield return(new SpriteActorPreview(anim, offset, zOffset, p, rs.Scale)); }
public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { if (UpgradeMinEnabledLevel > 0) { yield break; } var body = init.Actor.TraitInfo <BodyOrientationInfo>(); var armament = init.Actor.TraitInfos <ArmamentInfo>() .First(a => a.Name == Armament); var t = init.Actor.TraitInfos <TurretedInfo>() .First(tt => tt.Turret == armament.Turret); var anim = new Animation(init.World, image, () => t.InitialFacing); anim.Play(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence)); var turretOrientation = body.QuantizeOrientation(new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(t.InitialFacing)), facings); var turretOffset = body.LocalToWorld(t.Offset.Rotate(turretOrientation)); yield return(new SpriteActorPreview(anim, turretOffset, turretOffset.Y + turretOffset.Z, p, rs.Scale)); }
public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { if (UpgradeMinEnabledLevel > 0) { yield break; } if (Palette != null) { p = init.WorldRenderer.Palette(Palette); } var body = init.Actor.TraitInfo <BodyOrientationInfo>(); var facing = init.Contains <FacingInit>() ? init.Get <FacingInit, int>() : 0; var anim = new Animation(init.World, image, () => facing); anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence)); var orientation = body.QuantizeOrientation(new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing)), facings); var offset = body.LocalToWorld(Offset.Rotate(orientation)); yield return(new SpriteActorPreview(anim, offset, offset.Y + offset.Z + 1, p, rs.Scale)); }
public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, string image, int facings, PaletteReference p) { if (!EnabledByDefault) { yield break; } var body = init.Actor.TraitInfo <BodyOrientationInfo>(); var t = init.Actor.TraitInfos <TurretedInfo>() .First(tt => tt.Turret == Turret); var turretFacing = t.WorldFacingFromInit(init); var anim = new Animation(init.World, image, turretFacing); anim.Play(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence)); var facing = init.GetFacing(); Func <WRot> orientation = () => body.QuantizeOrientation(WRot.FromYaw(facing()), facings); Func <WVec> offset = () => body.LocalToWorld(t.Offset.Rotate(orientation())); Func <int> zOffset = () => { var tmpOffset = offset(); return(-(tmpOffset.Y + tmpOffset.Z) + 1); }; if (IsPlayerPalette) { p = init.WorldRenderer.Palette(Palette + init.Get <OwnerInit>().InternalName); } else if (Palette != null) { p = init.WorldRenderer.Palette(Palette); } yield return(new SpriteActorPreview(anim, offset, zOffset, p)); }
void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e) { overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, overlay.CurrentSequence.Name)); }
public override IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { if (!EnabledByDefault) { yield break; } var adjacent = 0; if (init.Contains <RuntimeNeighbourInit>()) { var location = CPos.Zero; if (init.Contains <LocationInit>()) { location = init.Get <LocationInit, CPos>(); } var neighbours = init.Get <RuntimeNeighbourInit, Dictionary <CPos, string[]> >(); foreach (var kv in neighbours) { var haveNeighbour = false; foreach (var n in kv.Value) { var rb = init.World.Map.Rules.Actors[n].TraitInfos <IWallConnectorInfo>().FirstEnabledTraitOrDefault(); if (rb != null && rb.GetWallConnectionType() == Type) { haveNeighbour = true; break; } } if (!haveNeighbour) { continue; } if (kv.Key == location + new CVec(0, -1)) { adjacent |= 1; } else if (kv.Key == location + new CVec(+1, 0)) { adjacent |= 2; } else if (kv.Key == location + new CVec(0, +1)) { adjacent |= 4; } else if (kv.Key == location + new CVec(-1, 0)) { adjacent |= 8; } } } var anim = new Animation(init.World, image, () => 0); anim.PlayFetchIndex(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence), () => adjacent); yield return(new SpriteActorPreview(anim, () => WVec.Zero, () => 0, p, rs.Scale)); }
public void Charging(Actor self, Target target) { charging = true; overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence), () => charging = false); }
public void DamageStateChanged(Actor self, AttackInfo e) { overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, info.Sequence)); }
public string NormalizeSequence(Actor self, string sequence) { return(RenderSprites.NormalizeSequence(DefaultAnimation, self.GetDamageState(), sequence)); }
void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e) { if (door.CurrentSequence != null) door.ReplaceAnim(RenderSprites.NormalizeSequence(door, e.DamageState, door.CurrentSequence.Name)); }