mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 09:46:02 +08:00
[csharp] Changed interface hierarchy of Posed to hide internal methods from the API.
This commit is contained in:
parent
6b978fcdf4
commit
d2f0ace521
@ -30,8 +30,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
|
internal interface IPosedInternal {
|
||||||
public interface IPosed {
|
|
||||||
// replaces "object.pose == object.applied" of reference implementation.
|
// replaces "object.pose == object.applied" of reference implementation.
|
||||||
bool PoseEqualsApplied { get; }
|
bool PoseEqualsApplied { get; }
|
||||||
// replaces "object.applied = object.pose" of reference implementation.
|
// replaces "object.applied = object.pose" of reference implementation.
|
||||||
@ -40,10 +39,13 @@ namespace Spine {
|
|||||||
void UseConstrained ();
|
void UseConstrained ();
|
||||||
// replaces "object.applied.Set(object.pose)" of reference implementation.
|
// replaces "object.applied.Set(object.pose)" of reference implementation.
|
||||||
void ResetConstrained ();
|
void ResetConstrained ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IPosed {
|
||||||
void SetupPose ();
|
void SetupPose ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Posed<D, P, A> : IPosed
|
public class Posed<D, P, A> : IPosed, IPosedInternal
|
||||||
where D : PosedData<P>
|
where D : PosedData<P>
|
||||||
where P : IPose<P>
|
where P : IPose<P>
|
||||||
where A : P {
|
where A : P {
|
||||||
@ -65,19 +67,19 @@ namespace Spine {
|
|||||||
pose.Set(data.setup);
|
pose.Set(data.setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool PoseEqualsApplied {
|
bool IPosedInternal.PoseEqualsApplied {
|
||||||
get { return (object)pose == (object)applied; }
|
get { return (object)pose == (object)applied; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UsePose () {
|
void IPosedInternal.UsePose () {
|
||||||
applied = pose;
|
applied = pose;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseConstrained () {
|
void IPosedInternal.UseConstrained () {
|
||||||
applied = constrained;
|
applied = constrained;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetConstrained () {
|
void IPosedInternal.ResetConstrained () {
|
||||||
applied.Set(pose);
|
applied.Set(pose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -46,7 +46,7 @@ namespace Spine {
|
|||||||
internal ExposedList<IConstraint> constraints;
|
internal ExposedList<IConstraint> constraints;
|
||||||
internal ExposedList<PhysicsConstraint> physics;
|
internal ExposedList<PhysicsConstraint> physics;
|
||||||
internal ExposedList<object> updateCache = new ExposedList<object>();
|
internal ExposedList<object> updateCache = new ExposedList<object>();
|
||||||
internal ExposedList<IPosed> resetCache = new ExposedList<IPosed>(16);
|
internal ExposedList<IPosedInternal> resetCache = new ExposedList<IPosedInternal>(16);
|
||||||
internal Skin skin;
|
internal Skin skin;
|
||||||
// Color is a struct, set to protected to prevent
|
// Color is a struct, set to protected to prevent
|
||||||
// Color color = slot.color; color.a = 0.5;
|
// Color color = slot.color; color.a = 0.5;
|
||||||
@ -156,7 +156,7 @@ namespace Spine {
|
|||||||
|
|
||||||
Slot[] slots = this.slots.Items;
|
Slot[] slots = this.slots.Items;
|
||||||
for (int i = 0, n = this.slots.Count; i < n; i++) {
|
for (int i = 0, n = this.slots.Count; i < n; i++) {
|
||||||
slots[i].UsePose();
|
((IPosedInternal)slots[i]).UsePose();
|
||||||
}
|
}
|
||||||
|
|
||||||
int boneCount = this.bones.Count;
|
int boneCount = this.bones.Count;
|
||||||
@ -165,7 +165,7 @@ namespace Spine {
|
|||||||
Bone bone = bones[i];
|
Bone bone = bones[i];
|
||||||
bone.sorted = bone.data.skinRequired;
|
bone.sorted = bone.data.skinRequired;
|
||||||
bone.active = !bone.sorted;
|
bone.active = !bone.sorted;
|
||||||
bone.UsePose();
|
((IPosedInternal)bone).UsePose();
|
||||||
}
|
}
|
||||||
if (skin != null) {
|
if (skin != null) {
|
||||||
BoneData[] skinBones = skin.bones.Items;
|
BoneData[] skinBones = skin.bones.Items;
|
||||||
@ -183,7 +183,7 @@ namespace Spine {
|
|||||||
{ // scope added to prevent compile error of n already being declared in enclosing scope
|
{ // scope added to prevent compile error of n already being declared in enclosing scope
|
||||||
int n = this.constraints.Count;
|
int n = this.constraints.Count;
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
constraints[i].UsePose();
|
((IPosedInternal)constraints[i]).UsePose();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
IConstraint constraint = constraints[i];
|
IConstraint constraint = constraints[i];
|
||||||
@ -204,7 +204,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Constrained (IPosed obj) {
|
internal void Constrained (IPosedInternal obj) {
|
||||||
if (obj.PoseEqualsApplied) { // if (obj.pose == obj.applied) {
|
if (obj.PoseEqualsApplied) { // if (obj.pose == obj.applied) {
|
||||||
obj.UseConstrained();
|
obj.UseConstrained();
|
||||||
resetCache.Add(obj);
|
resetCache.Add(obj);
|
||||||
@ -239,7 +239,7 @@ namespace Spine {
|
|||||||
public void UpdateWorldTransform (Physics physics) {
|
public void UpdateWorldTransform (Physics physics) {
|
||||||
update++;
|
update++;
|
||||||
|
|
||||||
IPosed[] resetCache = this.resetCache.Items;
|
IPosedInternal[] resetCache = this.resetCache.Items;
|
||||||
for (int i = 0, n = this.resetCache.Count; i < n; i++) {
|
for (int i = 0, n = this.resetCache.Count; i < n; i++) {
|
||||||
resetCache[i].ResetConstrained();
|
resetCache[i].ResetConstrained();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,10 +102,10 @@ namespace Spine {
|
|||||||
for (int ii = 0; ii < physicsCount; ii++)
|
for (int ii = 0; ii < physicsCount; ii++)
|
||||||
skeleton.Constrained(physics[ii]);
|
skeleton.Constrained(physics[ii]);
|
||||||
} else
|
} else
|
||||||
skeleton.Constrained(constraints[timeline.constraintIndex]);
|
skeleton.Constrained((IPosedInternal)constraints[timeline.constraintIndex]);
|
||||||
} else if (t as IConstraintTimeline != null) {
|
} else if (t as IConstraintTimeline != null) {
|
||||||
IConstraintTimeline timeline = (IConstraintTimeline)t;
|
IConstraintTimeline timeline = (IConstraintTimeline)t;
|
||||||
skeleton.Constrained(constraints[timeline.ConstraintIndex]);
|
skeleton.Constrained((IPosedInternal)constraints[timeline.ConstraintIndex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "com.esotericsoftware.spine.spine-csharp",
|
"name": "com.esotericsoftware.spine.spine-csharp",
|
||||||
"displayName": "spine-csharp Runtime",
|
"displayName": "spine-csharp Runtime",
|
||||||
"description": "This plugin provides the spine-csharp core runtime.",
|
"description": "This plugin provides the spine-csharp core runtime.",
|
||||||
"version": "4.3.3",
|
"version": "4.3.4",
|
||||||
"unity": "2018.3",
|
"unity": "2018.3",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Esoteric Software",
|
"name": "Esoteric Software",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user