mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-25 22:23:42 +08:00
[csharp] Port of commit 1cef139: Improved SequenceTimeline for RegionAttachment copies, moved timelineAttachment to Attachment. Revert of temp changes f3f557, see #3040.
This commit is contained in:
parent
831cf1a488
commit
5620b65028
@ -1898,6 +1898,9 @@ namespace Spine {
|
||||
return slotIndex;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The attachment for which the <see cref="SlotPose.SequenceIndex"/> will be set.</summary>
|
||||
/// <seealso cref="Attachment.TimelineAttachment"/>.
|
||||
public Attachment Attachment {
|
||||
get {
|
||||
return (Attachment)attachment;
|
||||
@ -1922,11 +1925,8 @@ namespace Spine {
|
||||
SlotPose pose = appliedPose ? slot.applied : slot.pose;
|
||||
|
||||
Attachment slotAttachment = pose.attachment;
|
||||
if (slotAttachment != attachment) {
|
||||
IHasSequence sequenceAttachment = slotAttachment as IHasSequence;
|
||||
if ((sequenceAttachment == null)
|
||||
|| sequenceAttachment.TimelineAttachment != attachment) return;
|
||||
}
|
||||
IHasSequence hasSequence = slotAttachment as IHasSequence;
|
||||
if ((hasSequence == null) || slotAttachment.TimelineAttachment != attachment) return;
|
||||
|
||||
if (direction == MixDirection.Out) {
|
||||
if (blend == MixBlend.Setup) pose.SequenceIndex = -1;
|
||||
@ -1944,7 +1944,7 @@ namespace Spine {
|
||||
int modeAndIndex = (int)frames[i + MODE];
|
||||
float delay = frames[i + DELAY];
|
||||
|
||||
int index = modeAndIndex >> 4, count = (((IHasSequence)slotAttachment).Sequence).Regions.Length;
|
||||
int index = modeAndIndex >> 4, count = hasSequence.Sequence.Regions.Length;
|
||||
SequenceMode mode = (SequenceMode)(modeAndIndex & 0xf);
|
||||
if (mode != SequenceMode.Hold) {
|
||||
index += (int)((time - before) / delay + 0.0001f);
|
||||
|
||||
@ -33,17 +33,25 @@ namespace Spine {
|
||||
|
||||
/// <summary>The base class for all attachments.</summary>
|
||||
abstract public class Attachment {
|
||||
internal Attachment timelineAttachment;
|
||||
|
||||
/// <summary>The attachment's name.</summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>Timelines for the timeline attachment are also applied to this attachment.
|
||||
/// May be null if no attachment-specific timelines should be applied.</summary>
|
||||
public Attachment TimelineAttachment { get { return timelineAttachment; } set { timelineAttachment = value; } }
|
||||
|
||||
protected Attachment (string name) {
|
||||
if (name == null) throw new ArgumentNullException("name", "name cannot be null");
|
||||
this.Name = name;
|
||||
timelineAttachment = this;
|
||||
}
|
||||
|
||||
/// <summary>Copy constructor.</summary>
|
||||
protected Attachment (Attachment other) {
|
||||
Name = other.Name;
|
||||
timelineAttachment = other.timelineAttachment;
|
||||
}
|
||||
|
||||
override public string ToString () {
|
||||
|
||||
@ -42,9 +42,6 @@ namespace Spine {
|
||||
void SetColor (Color32F color);
|
||||
void SetColor (float r, float g, float b, float a);
|
||||
Sequence Sequence { get; }
|
||||
/// <summary>Timelines for the timeline attachment are also applied to this attachment.
|
||||
/// May be null if no attachment-specific timelines should be applied.</summary>
|
||||
Attachment TimelineAttachment { get; set; }
|
||||
void UpdateSequence ();
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,11 +73,7 @@ namespace Spine {
|
||||
|
||||
public string Path { get { return path; } set { path = value; } }
|
||||
public Sequence Sequence { get { return sequence; } }
|
||||
Attachment IHasSequence.TimelineAttachment {
|
||||
get { return timelineAttachment; }
|
||||
set { timelineAttachment = (VertexAttachment)value; }
|
||||
}
|
||||
|
||||
|
||||
public MeshAttachment ParentMesh {
|
||||
get { return parentMesh; }
|
||||
set {
|
||||
|
||||
@ -46,7 +46,6 @@ namespace Spine {
|
||||
public const int BRX = 6, BRY = 7;
|
||||
|
||||
internal readonly Sequence sequence;
|
||||
internal Attachment timelineAttachment;
|
||||
internal float x, y, rotation, scaleX = 1, scaleY = 1, width, height;
|
||||
// Color is a struct, set to protected to prevent
|
||||
// Color color = slot.color; color.a = 0.5;
|
||||
@ -76,13 +75,11 @@ namespace Spine {
|
||||
|
||||
public string Path { get; set; }
|
||||
public Sequence Sequence { get { return sequence; } }
|
||||
public Attachment TimelineAttachment { get { return timelineAttachment; } set { timelineAttachment = value; } }
|
||||
|
||||
|
||||
public RegionAttachment (string name, Sequence sequence)
|
||||
: base(name) {
|
||||
if (sequence == null) throw new ArgumentException("sequence cannot be null.", "sequence");
|
||||
this.sequence = sequence;
|
||||
timelineAttachment = this;
|
||||
}
|
||||
|
||||
/// <summary>Copy constructor.</summary>
|
||||
@ -98,7 +95,6 @@ namespace Spine {
|
||||
height = other.height;
|
||||
color = other.color;
|
||||
sequence = new Sequence(other.sequence);
|
||||
timelineAttachment = other.timelineAttachment;
|
||||
}
|
||||
|
||||
/// <summary><para>
|
||||
|
||||
@ -37,7 +37,6 @@ namespace Spine {
|
||||
static readonly Object nextIdLock = new Object();
|
||||
|
||||
internal readonly int id;
|
||||
internal VertexAttachment timelineAttachment;
|
||||
internal int[] bones;
|
||||
internal float[] vertices;
|
||||
internal int worldVerticesLength;
|
||||
@ -47,17 +46,13 @@ namespace Spine {
|
||||
public int[] Bones { get { return bones; } set { bones = value; } }
|
||||
public float[] Vertices { get { return vertices; } set { vertices = value; } }
|
||||
public int WorldVerticesLength { get { return worldVerticesLength; } set { worldVerticesLength = value; } }
|
||||
/// <summary>Timelines for the timeline attachment are also applied to this attachment.
|
||||
/// May be null if no attachment-specific timelines should be applied.</summary>
|
||||
public VertexAttachment TimelineAttachment { get { return timelineAttachment; } set { timelineAttachment = value; } }
|
||||
|
||||
|
||||
public VertexAttachment (string name)
|
||||
: base(name) {
|
||||
|
||||
lock (VertexAttachment.nextIdLock) {
|
||||
id = VertexAttachment.nextID++;
|
||||
}
|
||||
timelineAttachment = this;
|
||||
}
|
||||
|
||||
/// <summary>Copy constructor.</summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user