From 01b8c06800fbf7c444100c14389a87eccdd8c6e3 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 22 Dec 2022 16:15:59 +0100 Subject: [PATCH] [csharp] Code cleanup: replaced var with explicit type names. --- spine-csharp/src/Animation.cs | 16 +- spine-csharp/src/AnimationState.cs | 8 +- spine-csharp/src/Atlas.cs | 12 +- spine-csharp/src/ExposedList.cs | 2 +- spine-csharp/src/IkConstraint.cs | 2 +- spine-csharp/src/Json.cs | 20 +- spine-csharp/src/Skeleton.cs | 41 ++--- spine-csharp/src/SkeletonBinary.cs | 38 ++-- spine-csharp/src/SkeletonClipping.cs | 12 +- spine-csharp/src/SkeletonData.cs | 12 +- spine-csharp/src/SkeletonJson.cs | 160 ++++++++-------- spine-csharp/src/Skin.cs | 8 +- spine-csharp/src/TransformConstraint.cs | 8 +- spine-csharp/src/Triangulator.cs | 24 +-- spine-csharp/tests/src/AnimationStateTests.cs | 2 +- .../SpineAnimationTesterTool.cs | 8 +- .../SpineBlinkPlayer.cs | 3 +- .../SpineboyBeginnerModel.cs | 2 +- .../SpineboyBeginnerView.cs | 12 +- .../SpineboyTargetController.cs | 6 +- .../TransitionDictionaryExample.cs | 2 +- .../Spine Examples/Scripts/HurtFlashEffect.cs | 2 +- .../SkeletonAnimationHandleExample.cs | 18 +- .../AnimationMatchModifierAsset.cs | 60 +++--- .../EquipButtonExample.cs | 2 +- .../EquipSystemExample.cs | 10 +- .../EquipsVisualsComponentExample.cs | 4 +- .../MixAndMatchSkinsButtonExample.cs | 2 +- .../MixAndMatchSkinsExample.cs | 14 +- .../Spine Examples/Scripts/MixAndMatch.cs | 10 +- .../Scripts/MixAndMatchGraphic.cs | 10 +- .../Spine Examples/Scripts/RaggedySpineboy.cs | 2 +- .../Scripts/Sample Components/CombinedSkin.cs | 10 +- .../Sample Components/Ghost/SkeletonGhost.cs | 8 +- .../Legacy/AtlasRegionAttacher.cs | 6 +- .../Legacy/SpriteAttacher.cs | 20 +- .../OutlineSkeletonGraphic.cs | 2 +- .../Sample Components/RenderExistingMesh.cs | 10 +- .../JitterEffectExample.cs | 6 +- .../TwoByTwoTransformEffectExample.cs | 4 +- .../SetRigidbodySolverIterations.cs | 6 +- .../SkeletonColorInitialize.cs | 12 +- .../SkeletonGraphicPlayAnimationAtEvent.cs | 4 +- .../SkeletonGraphicRenderTexture.cs | 10 +- .../SkeletonRagdoll.cs | 66 +++---- .../SkeletonRagdoll2D.cs | 66 +++---- .../SkeletonUtilityKinematicShadow.cs | 18 +- .../SpineEventUnityHandler.cs | 14 +- .../Scripts/SpawnFromSkeletonDataExample.cs | 4 +- .../Scripts/SpawnSkeletonGraphicExample.cs | 2 +- .../Spine Examples/Scripts/SpineGauge.cs | 2 +- .../Assets/Spine Examples/Scripts/Spineboy.cs | 2 +- .../Scripts/SpineboyBodyTilt.cs | 4 +- .../Scripts/SpineboyFacialExpression.cs | 4 +- .../Scripts/SpineboyFootplanter.cs | 8 +- .../Spine Examples/Scripts/SpineboyFreeze.cs | 4 +- .../Spine Examples/Scripts/SpineboyPole.cs | 6 +- .../Scripts/SpineboyPoleGraphic.cs | 6 +- .../AnimationReferenceAssetEditor.cs | 2 +- .../Asset Types/SkeletonDataAssetInspector.cs | 68 +++---- .../Asset Types/SpineAtlasAssetInspector.cs | 26 +-- .../SpineSpriteAtlasAssetInspector.cs | 4 +- .../BoneFollowerGraphicInspector.cs | 32 ++-- .../Components/BoneFollowerInspector.cs | 34 ++-- .../BoundingBoxFollowerGraphicInspector.cs | 36 ++-- .../BoundingBoxFollowerInspector.cs | 42 ++--- .../Components/PointFollowerInspector.cs | 36 ++-- .../Components/SkeletonAnimationInspector.cs | 10 +- ...SkeletonGraphicCustomMaterialsInspector.cs | 8 +- .../Components/SkeletonGraphicInspector.cs | 71 ++++---- .../Components/SkeletonMecanimInspector.cs | 20 +- .../SkeletonMecanimRootMotionInspector.cs | 4 +- ...keletonRendererCustomMaterialsInspector.cs | 8 +- .../Components/SkeletonRendererInspector.cs | 77 ++++---- .../SkeletonRootMotionBaseInspector.cs | 4 +- .../SkeletonUtilityBoneInspector.cs | 76 ++++---- .../Components/SkeletonUtilityInspector.cs | 6 +- .../Shaders/SpineShaderWithOutlineGUI.cs | 6 +- .../Editor/Shaders/SpineSpriteShaderGUI.cs | 4 +- .../Editor/SpineAttributeDrawers.cs | 78 ++++---- .../Editor/Utility/AssetUtility.cs | 92 +++++----- .../Utility/BlendModeMaterialsUtility.cs | 40 ++-- .../Editor/Utility/DataReloadHandler.cs | 34 ++-- .../Editor/Utility/Instantiation.cs | 22 +-- .../spine-unity/Editor/Utility/Preferences.cs | 26 +-- .../Editor/Utility/SpineBuildProcessor.cs | 10 +- .../Editor/Utility/SpineEditorUtilities.cs | 30 +-- .../Editor/Utility/SpineHandles.cs | 48 ++--- .../Editor/Utility/SpineInspectorUtility.cs | 18 +- .../Editor/Utility/SpineMaskUtilities.cs | 80 ++++---- .../Editor/Windows/SkeletonBaker.cs | 129 ++++++------- .../Editor/Windows/SkeletonBakingWindow.cs | 10 +- .../Editor/Windows/SkeletonDebugWindow.cs | 49 +++-- .../Editor/Windows/SpinePreferences.cs | 12 +- .../Editor/Windows/SpriteAtlasImportWindow.cs | 8 +- .../Editor/SkeletonPartsRendererInspector.cs | 8 +- .../SkeletonRenderSeparatorInspector.cs | 44 ++--- .../Asset Types/BlendModeMaterials.cs | 36 ++-- .../Asset Types/SkeletonDataAsset.cs | 16 +- .../Asset Types/SkeletonDataCompatibility.cs | 10 +- .../Asset Types/SpineAtlasAsset.cs | 4 +- .../Asset Types/SpineSpriteAtlasAsset.cs | 40 ++-- .../Components/Following/BoneFollower.cs | 2 +- .../Following/BoneFollowerGraphic.cs | 4 +- .../Following/BoundingBoxFollower.cs | 26 +-- .../Following/BoundingBoxFollowerGraphic.cs | 28 +-- .../Components/Following/PointFollower.cs | 4 +- .../RootMotion/SkeletonMecanimRootMotion.cs | 12 +- .../RootMotion/SkeletonRootMotion.cs | 14 +- .../RootMotion/SkeletonRootMotionBase.cs | 28 +-- .../Components/SkeletonAnimation.cs | 4 +- .../spine-unity/Components/SkeletonGraphic.cs | 76 ++++---- .../spine-unity/Components/SkeletonMecanim.cs | 47 ++--- .../SkeletonPartsRenderer.cs | 10 +- .../SkeletonRenderSeparator.cs | 30 +-- .../Components/SkeletonRenderer.cs | 48 ++--- .../SkeletonGraphicCustomMaterials.cs | 12 +- .../SkeletonRendererCustomMaterials.cs | 6 +- .../ActivateBasedOnFlipDirection.cs | 4 +- .../SkeletonUtility/SkeletonUtility.cs | 36 ++-- .../SkeletonUtility/SkeletonUtilityBone.cs | 4 +- .../Mesh Generation/MeshGenerator.cs | 172 +++++++++--------- .../Mesh Generation/MeshRendererBuffers.cs | 8 +- .../SkeletonRendererInstruction.cs | 26 +-- .../spine-unity/Mesh Generation/SpineMesh.cs | 2 +- .../BlendModeMaterialsAsset.cs | 18 +- .../Runtime/spine-unity/SpineAttributes.cs | 4 +- .../spine-unity/Utility/AtlasUtilities.cs | 80 ++++---- .../Utility/AttachmentCloneExtensions.cs | 8 +- .../Utility/AttachmentRegionExtensions.cs | 14 +- .../spine-unity/Utility/MaterialChecks.cs | 8 +- .../spine-unity/Utility/SkeletonExtensions.cs | 16 +- .../spine-unity/Utility/TimelineExtensions.cs | 12 +- .../editor-tests/RunAnimationStateTests.cs | 4 +- .../SpineAnimationStateClipInspector.cs | 10 +- ...pineAnimationStateGraphicTrackInspector.cs | 2 +- .../SpineAnimationStateTrackInspector.cs | 2 +- .../Editor/SpineSkeletonFlipClipEditor.cs | 8 +- .../Editor/SpineSkeletonFlipTrackInspector.cs | 2 +- .../SpineAnimationStateGraphicTrack.cs | 4 +- .../SpineAnimationStateMixerBehaviour.cs | 26 +-- .../SpineAnimationStateTrack.cs | 4 +- .../SpineSkeletonFlipMixerBehaviour.cs | 4 +- .../SpineSkeletonFlipTrack.cs | 4 +- 144 files changed, 1539 insertions(+), 1548 deletions(-) diff --git a/spine-csharp/src/Animation.cs b/spine-csharp/src/Animation.cs index 58851447d..8d1c3bd57 100644 --- a/spine-csharp/src/Animation.cs +++ b/spine-csharp/src/Animation.cs @@ -66,7 +66,7 @@ namespace Spine { string[] propertyIds = new string[idCount]; int currentId = 0; for (int t = 0; t < timelinesCount; ++t) { - var ids = timelinesItems[t].PropertyIds; + string[] ids = timelinesItems[t].PropertyIds; for (int i = 0, idsLength = ids.Length; i < idsLength; ++i) propertyIds[currentId++] = ids[i]; } @@ -115,7 +115,7 @@ namespace Spine { if (lastTime > 0) lastTime %= duration; } - var timelines = this.timelines.Items; + Timeline[] timelines = this.timelines.Items; for (int i = 0, n = this.timelines.Count; i < n; i++) timelines[i].Apply(skeleton, lastTime, time, events, alpha, blend, direction); } @@ -1173,7 +1173,7 @@ namespace Spine { float[] frames = this.frames; if (time < frames[0]) { // Time is before first frame. - var setup = slot.data; + SlotData setup = slot.data; switch (blend) { case MixBlend.Setup: slot.r = setup.r; @@ -1289,7 +1289,7 @@ namespace Spine { float[] frames = this.frames; if (time < frames[0]) { // Time is before first frame. - var setup = slot.data; + SlotData setup = slot.data; switch (blend) { case MixBlend.Setup: slot.r = setup.r; @@ -1338,7 +1338,7 @@ namespace Spine { } else { float br, bg, bb; if (blend == MixBlend.Setup) { - var setup = slot.data; + SlotData setup = slot.data; br = setup.r; bg = setup.g; bb = setup.b; @@ -1377,7 +1377,7 @@ namespace Spine { float[] frames = this.frames; if (time < frames[0]) { // Time is before first frame. - var setup = slot.data; + SlotData setup = slot.data; switch (blend) { case MixBlend.Setup: slot.a = setup.a; @@ -1869,10 +1869,10 @@ namespace Spine { Slot slot = skeleton.slots.Items[slotIndex]; if (!slot.bone.active) return; - var vertexAttachment = slot.attachment as VertexAttachment; + VertexAttachment vertexAttachment = slot.attachment as VertexAttachment; if (vertexAttachment == null || vertexAttachment.TimelineAttachment != attachment) return; - var deformArray = slot.deform; + ExposedList deformArray = slot.deform; if (deformArray.Count == 0) blend = MixBlend.Setup; float[][] vertices = this.vertices; diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs index abab61c1a..d11b9051a 100644 --- a/spine-csharp/src/AnimationState.cs +++ b/spine-csharp/src/AnimationState.cs @@ -276,7 +276,7 @@ namespace Spine { for (int ii = 0; ii < timelineCount; ii++) { Timeline timeline = timelines[ii]; MixBlend timelineBlend = timelineMode[ii] == AnimationState.Subsequent ? blend : MixBlend.Setup; - var rotateTimeline = timeline as RotateTimeline; + RotateTimeline rotateTimeline = timeline as RotateTimeline; if (!shortestRotation && rotateTimeline != null) ApplyRotateTimeline(rotateTimeline, skeleton, applyTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame); @@ -420,7 +420,7 @@ namespace Spine { break; } from.totalAlpha += alpha; - var rotateTimeline = timeline as RotateTimeline; + RotateTimeline rotateTimeline = timeline as RotateTimeline; if (!shortestRotation && rotateTimeline != null) { ApplyRotateTimeline(rotateTimeline, skeleton, applyTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame); @@ -953,7 +953,7 @@ namespace Spine { public ExposedList Tracks { get { return tracks; } } override public string ToString () { - var buffer = new System.Text.StringBuilder(); + System.Text.StringBuilder buffer = new System.Text.StringBuilder(); TrackEntry[] tracksItems = tracks.Items; for (int i = 0, n = tracks.Count; i < n; i++) { TrackEntry entry = tracksItems[i]; @@ -1435,7 +1435,7 @@ namespace Spine { } protected void Reset (T obj) { - var poolable = obj as IPoolable; + IPoolable poolable = obj as IPoolable; if (poolable != null) poolable.Reset(); } diff --git a/spine-csharp/src/Atlas.cs b/spine-csharp/src/Atlas.cs index c72cf5541..6e9c23cc6 100644 --- a/spine-csharp/src/Atlas.cs +++ b/spine-csharp/src/Atlas.cs @@ -63,10 +63,10 @@ namespace Spine { #if !(IS_UNITY) #if WINDOWS_STOREAPP - private async Task ReadFile(string path, TextureLoader textureLoader) { + private async Task ReadFile (string path, TextureLoader textureLoader) { var folder = Windows.ApplicationModel.Package.Current.InstalledLocation; var file = await folder.GetFileAsync(path).AsTask().ConfigureAwait(false); - using (var reader = new StreamReader(await file.OpenStreamForReadAsync().ConfigureAwait(false))) { + using (StreamReader reader = new StreamReader(await file.OpenStreamForReadAsync().ConfigureAwait(false))) { try { Atlas atlas = new Atlas(reader, Path.GetDirectoryName(path), textureLoader); this.pages = atlas.pages; @@ -78,7 +78,7 @@ namespace Spine { } } - public Atlas(string path, TextureLoader textureLoader) { + public Atlas (string path, TextureLoader textureLoader) { this.ReadFile(path, textureLoader).Wait(); } #else @@ -120,7 +120,7 @@ namespace Spine { AtlasPage page = null; AtlasRegion region = null; - var pageFields = new Dictionary(5); + Dictionary pageFields = new Dictionary(5); pageFields.Add("size", () => { page.width = int.Parse(entry[1], CultureInfo.InvariantCulture); page.height = int.Parse(entry[2], CultureInfo.InvariantCulture); @@ -140,7 +140,7 @@ namespace Spine { page.pma = entry[1] == "true"; }); - var regionFields = new Dictionary(8); + Dictionary regionFields = new Dictionary(8); regionFields.Add("xy", () => { // Deprecated, use bounds. region.x = int.Parse(entry[1], CultureInfo.InvariantCulture); region.y = int.Parse(entry[2], CultureInfo.InvariantCulture); @@ -246,7 +246,7 @@ namespace Spine { region.u2 = (region.x + region.height) / (float)page.width; region.v2 = (region.y + region.width) / (float)page.height; - var tempSwap = region.packedWidth; + int tempSwap = region.packedWidth; region.packedWidth = region.packedHeight; region.packedHeight = tempSwap; } else { diff --git a/spine-csharp/src/ExposedList.cs b/spine-csharp/src/ExposedList.cs index 325a43666..092999a1a 100644 --- a/spine-csharp/src/ExposedList.cs +++ b/spine-csharp/src/ExposedList.cs @@ -90,7 +90,7 @@ namespace Spine { public ExposedList Resize (int newSize) { int itemsLength = Items.Length; - var oldItems = Items; + T[] oldItems = Items; if (newSize > itemsLength) { Array.Resize(ref Items, newSize); } else if (newSize < itemsLength) { diff --git a/spine-csharp/src/IkConstraint.cs b/spine-csharp/src/IkConstraint.cs index 40f07baa3..b54773ecd 100644 --- a/spine-csharp/src/IkConstraint.cs +++ b/spine-csharp/src/IkConstraint.cs @@ -82,7 +82,7 @@ namespace Spine { public void Update () { if (mix == 0) return; Bone target = this.target; - var bones = this.bones.Items; + Bone[] bones = this.bones.Items; switch (this.bones.Count) { case 1: Apply(bones[0], target.worldX, target.worldY, compress, stretch, data.uniform, mix); diff --git a/spine-csharp/src/Json.cs b/spine-csharp/src/Json.cs index ffd5fbde0..7765b03da 100644 --- a/spine-csharp/src/Json.cs +++ b/spine-csharp/src/Json.cs @@ -37,7 +37,7 @@ using System.Text; namespace Spine { public static class Json { public static object Deserialize (TextReader text) { - var parser = new SharpJson.JsonDecoder(); + SharpJson.JsonDecoder parser = new SharpJson.JsonDecoder(); parser.parseNumbersAsFloat = true; return parser.Decode(text.ReadToEnd()); } @@ -175,7 +175,7 @@ namespace SharpJson { case 'u': int remainingLength = json.Length - index; if (remainingLength >= 4) { - var hex = new string(json, index, 4); + string hex = new string(json, index, 4); // XXX: handle UTF stringBuffer[idx++] = (char)Convert.ToInt32(hex, 16); @@ -217,7 +217,7 @@ namespace SharpJson { int lastIndex = GetLastIndexOfNumber(index); int charLength = (lastIndex - index) + 1; - var result = new string(json, index, charLength); + string result = new string(json, index, charLength); index = lastIndex + 1; @@ -226,7 +226,7 @@ namespace SharpJson { public float ParseFloatNumber () { float number; - var str = GetNumberString(); + string str = GetNumberString(); if (!float.TryParse(str, NumberStyles.Float, CultureInfo.InvariantCulture, out number)) return 0; @@ -236,7 +236,7 @@ namespace SharpJson { public double ParseDoubleNumber () { double number; - var str = GetNumberString(); + string str = GetNumberString(); if (!double.TryParse(str, NumberStyles.Any, CultureInfo.InvariantCulture, out number)) return 0; @@ -387,18 +387,18 @@ namespace SharpJson { } public static object DecodeText (string text) { - var builder = new JsonDecoder(); + JsonDecoder builder = new JsonDecoder(); return builder.Decode(text); } IDictionary ParseObject () { - var table = new Dictionary(); + Dictionary table = new Dictionary(); // { lexer.NextToken(); while (true) { - var token = lexer.LookAhead(); + Lexer.Token token = lexer.LookAhead(); switch (token) { case Lexer.Token.None: @@ -440,13 +440,13 @@ namespace SharpJson { } IList ParseArray () { - var array = new List(); + List array = new List(); // [ lexer.NextToken(); while (true) { - var token = lexer.LookAhead(); + Lexer.Token token = lexer.LookAhead(); switch (token) { case Lexer.Token.None: diff --git a/spine-csharp/src/Skeleton.cs b/spine-csharp/src/Skeleton.cs index 14c89b30d..1ebd36bfd 100644 --- a/spine-csharp/src/Skeleton.cs +++ b/spine-csharp/src/Skeleton.cs @@ -177,7 +177,7 @@ namespace Spine { /// Caches information about bones and constraints. Must be called if the is modified or if bones, constraints, or /// constraints, or weighted path attachments are added or removed. public void UpdateCache () { - var updateCache = this.updateCache; + ExposedList updateCache = this.updateCache; updateCache.Clear(); int boneCount = this.bones.Count; @@ -190,7 +190,7 @@ namespace Spine { if (skin != null) { BoneData[] skinBones = skin.bones.Items; for (int i = 0, n = skin.bones.Count; i < n; i++) { - var bone = bones[skinBones[i].index]; + Bone bone = bones[skinBones[i].index]; do { bone.sorted = false; bone.active = true; @@ -241,7 +241,7 @@ namespace Spine { Bone target = constraint.target; SortBone(target); - var constrained = constraint.bones; + ExposedList constrained = constraint.bones; Bone parent = constrained.Items[0]; SortBone(parent); @@ -266,7 +266,7 @@ namespace Spine { SortBone(constraint.target); - var constrained = constraint.bones.Items; + Bone[] constrained = constraint.bones.Items; int boneCount = constraint.bones.Count; if (constraint.data.local) { for (int i = 0; i < boneCount; i++) { @@ -302,7 +302,7 @@ namespace Spine { Attachment attachment = slot.attachment; if (attachment is PathAttachment) SortPathConstraintAttachment(attachment, slotBone); - var constrained = constraint.bones.Items; + Bone[] constrained = constraint.bones.Items; int boneCount = constraint.bones.Count; for (int i = 0; i < boneCount; i++) SortBone(constrained[i]); @@ -316,7 +316,7 @@ namespace Spine { } private void SortPathConstraintAttachment (Skin skin, int slotIndex, Bone slotBone) { - foreach (var entry in skin.Attachments) + foreach (Skin.SkinEntry entry in skin.Attachments) if (entry.SlotIndex == slotIndex) SortPathConstraintAttachment(entry.Attachment, slotBone); } @@ -326,7 +326,7 @@ namespace Spine { if (pathBones == null) SortBone(slotBone); else { - var bones = this.bones.Items; + Bone[] bones = this.bones.Items; for (int i = 0, n = pathBones.Length; i < n;) { int nn = pathBones[i++]; nn += i; @@ -373,7 +373,7 @@ namespace Spine { bone.ashearY = bone.shearY; } - var updateCache = this.updateCache.Items; + IUpdatable[] updateCache = this.updateCache.Items; for (int i = 0, n = this.updateCache.Count; i < n; i++) updateCache[i].Update(); } @@ -402,9 +402,9 @@ namespace Spine { rootBone.d = (pc * lb + pd * ld) * scaleY; // Update everything except root bone. - var updateCache = this.updateCache.Items; + IUpdatable[] updateCache = this.updateCache.Items; for (int i = 0, n = this.updateCache.Count; i < n; i++) { - var updatable = updateCache[i]; + IUpdatable updatable = updateCache[i]; if (updatable != rootBone) updatable.Update(); } } @@ -417,7 +417,7 @@ namespace Spine { /// Sets the bones and constraints to their setup pose values. public void SetBonesToSetupPose () { - var bones = this.bones.Items; + Bone[] bones = this.bones.Items; for (int i = 0, n = this.bones.Count; i < n; i++) bones[i].SetToSetupPose(); @@ -457,7 +457,7 @@ namespace Spine { } public void SetSlotsToSetupPose () { - var slots = this.slots.Items; + Slot[] slots = this.slots.Items; int n = this.slots.Count; Array.Copy(slots, 0, drawOrder.Items, 0, n); for (int i = 0; i < n; i++) @@ -469,7 +469,7 @@ namespace Spine { /// May be null. public Bone FindBone (string boneName) { if (boneName == null) throw new ArgumentNullException("boneName", "boneName cannot be null."); - var bones = this.bones.Items; + Bone[] bones = this.bones.Items; for (int i = 0, n = this.bones.Count; i < n; i++) { Bone bone = bones[i]; if (bone.data.name == boneName) return bone; @@ -482,7 +482,7 @@ namespace Spine { /// May be null. public Slot FindSlot (string slotName) { if (slotName == null) throw new ArgumentNullException("slotName", "slotName cannot be null."); - var slots = this.slots.Items; + Slot[] slots = this.slots.Items; for (int i = 0, n = this.slots.Count; i < n; i++) { Slot slot = slots[i]; if (slot.data.name == slotName) return slot; @@ -573,7 +573,7 @@ namespace Spine { /// May be null. public IkConstraint FindIkConstraint (string constraintName) { if (constraintName == null) throw new ArgumentNullException("constraintName", "constraintName cannot be null."); - var ikConstraints = this.ikConstraints.Items; + IkConstraint[] ikConstraints = this.ikConstraints.Items; for (int i = 0, n = this.ikConstraints.Count; i < n; i++) { IkConstraint ikConstraint = ikConstraints[i]; if (ikConstraint.data.name == constraintName) return ikConstraint; @@ -586,7 +586,7 @@ namespace Spine { /// May be null. public TransformConstraint FindTransformConstraint (string constraintName) { if (constraintName == null) throw new ArgumentNullException("constraintName", "constraintName cannot be null."); - var transformConstraints = this.transformConstraints.Items; + TransformConstraint[] transformConstraints = this.transformConstraints.Items; for (int i = 0, n = this.transformConstraints.Count; i < n; i++) { TransformConstraint transformConstraint = transformConstraints[i]; if (transformConstraint.data.Name == constraintName) return transformConstraint; @@ -599,7 +599,7 @@ namespace Spine { /// May be null. public PathConstraint FindPathConstraint (string constraintName) { if (constraintName == null) throw new ArgumentNullException("constraintName", "constraintName cannot be null."); - var pathConstraints = this.pathConstraints.Items; + PathConstraint[] pathConstraints = this.pathConstraints.Items; for (int i = 0, n = this.pathConstraints.Count; i < n; i++) { PathConstraint constraint = pathConstraints[i]; if (constraint.data.Name.Equals(constraintName)) return constraint; @@ -616,7 +616,7 @@ namespace Spine { public void GetBounds (out float x, out float y, out float width, out float height, ref float[] vertexBuffer) { float[] temp = vertexBuffer; temp = temp ?? new float[8]; - var drawOrder = this.drawOrder.Items; + Slot[] drawOrder = this.drawOrder.Items; float minX = int.MaxValue, minY = int.MaxValue, maxX = int.MinValue, maxY = int.MinValue; for (int i = 0, n = this.drawOrder.Count; i < n; i++) { Slot slot = drawOrder[i]; @@ -631,9 +631,8 @@ namespace Spine { if (vertices.Length < 8) vertices = temp = new float[8]; region.ComputeWorldVertices(slot, temp, 0, 2); } else { - var meshAttachment = attachment as MeshAttachment; - if (meshAttachment != null) { - MeshAttachment mesh = meshAttachment; + MeshAttachment mesh = attachment as MeshAttachment; + if (mesh != null) { verticesLength = mesh.WorldVerticesLength; vertices = temp; if (vertices.Length < verticesLength) vertices = temp = new float[verticesLength]; diff --git a/spine-csharp/src/SkeletonBinary.cs b/spine-csharp/src/SkeletonBinary.cs index 3e5695f0d..d55239cbb 100644 --- a/spine-csharp/src/SkeletonBinary.cs +++ b/spine-csharp/src/SkeletonBinary.cs @@ -83,7 +83,7 @@ namespace Spine { #if !ISUNITY && WINDOWS_STOREAPP private async Task ReadFile(string path) { var folder = Windows.ApplicationModel.Package.Current.InstalledLocation; - using (var input = new BufferedStream(await folder.GetFileAsync(path).AsTask().ConfigureAwait(false))) { + using (BufferedStream input = new BufferedStream(await folder.GetFileAsync(path).AsTask().ConfigureAwait(false))) { SkeletonData skeletonData = ReadSkeletonData(input); skeletonData.Name = Path.GetFileNameWithoutExtension(path); return skeletonData; @@ -96,9 +96,9 @@ namespace Spine { #else public override SkeletonData ReadSkeletonData (string path) { #if WINDOWS_PHONE - using (var input = new BufferedStream(Microsoft.Xna.Framework.TitleContainer.OpenStream(path))) { + using (BufferedStream input = new BufferedStream(Microsoft.Xna.Framework.TitleContainer.OpenStream(path))) { #else - using (var input = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) { + using (FileStream input = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) { #endif SkeletonData skeletonData = ReadSkeletonData(input); skeletonData.name = Path.GetFileNameWithoutExtension(path); @@ -127,7 +127,7 @@ namespace Spine { if (file == null) throw new ArgumentNullException("file"); float scale = this.scale; - var skeletonData = new SkeletonData(); + SkeletonData skeletonData = new SkeletonData(); SkeletonInput input = new SkeletonInput(file); long hash = input.ReadLong(); @@ -162,7 +162,7 @@ namespace Spine { o[i] = input.ReadString(); // Bones. - var bones = skeletonData.bones.Resize(n = input.ReadInt(true)).Items; + BoneData[] bones = skeletonData.bones.Resize(n = input.ReadInt(true)).Items; for (int i = 0; i < n; i++) { String name = input.ReadString(); BoneData parent = i == 0 ? null : bones[input.ReadInt(true)]; @@ -182,7 +182,7 @@ namespace Spine { } // Slots. - var slots = skeletonData.slots.Resize(n = input.ReadInt(true)).Items; + SlotData[] slots = skeletonData.slots.Resize(n = input.ReadInt(true)).Items; for (int i = 0; i < n; i++) { String slotName = input.ReadString(); BoneData boneData = bones[input.ReadInt(true)]; @@ -212,7 +212,7 @@ namespace Spine { IkConstraintData data = new IkConstraintData(input.ReadString()); data.order = input.ReadInt(true); data.skinRequired = input.ReadBoolean(); - var constraintBones = data.bones.Resize(nn = input.ReadInt(true)).Items; + BoneData[] constraintBones = data.bones.Resize(nn = input.ReadInt(true)).Items; for (int ii = 0; ii < nn; ii++) constraintBones[ii] = bones[input.ReadInt(true)]; data.target = bones[input.ReadInt(true)]; @@ -231,7 +231,7 @@ namespace Spine { TransformConstraintData data = new TransformConstraintData(input.ReadString()); data.order = input.ReadInt(true); data.skinRequired = input.ReadBoolean(); - var constraintBones = data.bones.Resize(nn = input.ReadInt(true)).Items; + BoneData[] constraintBones = data.bones.Resize(nn = input.ReadInt(true)).Items; for (int ii = 0; ii < nn; ii++) constraintBones[ii] = bones[input.ReadInt(true)]; data.target = bones[input.ReadInt(true)]; @@ -341,17 +341,17 @@ namespace Spine { } else { skin = new Skin(input.ReadStringRef()); Object[] bones = skin.bones.Resize(input.ReadInt(true)).Items; - var bonesItems = skeletonData.bones.Items; + BoneData[] bonesItems = skeletonData.bones.Items; for (int i = 0, n = skin.bones.Count; i < n; i++) bones[i] = bonesItems[input.ReadInt(true)]; - var ikConstraintsItems = skeletonData.ikConstraints.Items; + IkConstraintData[] ikConstraintsItems = skeletonData.ikConstraints.Items; for (int i = 0, n = input.ReadInt(true); i < n; i++) skin.constraints.Add(ikConstraintsItems[input.ReadInt(true)]); - var transformConstraintsItems = skeletonData.transformConstraints.Items; + TransformConstraintData[] transformConstraintsItems = skeletonData.transformConstraints.Items; for (int i = 0, n = input.ReadInt(true); i < n; i++) skin.constraints.Add(transformConstraintsItems[input.ReadInt(true)]); - var pathConstraintsItems = skeletonData.pathConstraints.Items; + PathConstraintData[] pathConstraintsItems = skeletonData.pathConstraints.Items; for (int i = 0, n = input.ReadInt(true); i < n; i++) skin.constraints.Add(pathConstraintsItems[input.ReadInt(true)]); skin.constraints.TrimExcess(); @@ -561,8 +561,8 @@ namespace Spine { vertices.vertices = ReadFloatArray(input, verticesLength, scale); return vertices; } - var weights = new ExposedList(verticesLength * 3 * 3); - var bonesArray = new ExposedList(verticesLength * 3); + ExposedList weights = new ExposedList(verticesLength * 3 * 3); + ExposedList bonesArray = new ExposedList(verticesLength * 3); for (int i = 0; i < vertexCount; i++) { int boneCount = input.ReadInt(true); bonesArray.Add(boneCount); @@ -602,7 +602,7 @@ namespace Spine { /// SerializationException will be thrown when a Vertex attachment is not found. /// Throws IOException when a read operation fails. private Animation ReadAnimation (String name, SkeletonInput input, SkeletonData skeletonData) { - var timelines = new ExposedList(input.ReadInt(true)); + ExposedList timelines = new ExposedList(input.ReadInt(true)); float scale = this.scale; // Slot timelines. @@ -1049,7 +1049,7 @@ namespace Spine { } float duration = 0; - var items = timelines.Items; + Timeline[] items = timelines.Items; for (int i = 0, n = timelines.Count; i < n; i++) duration = Math.Max(duration, items[i].Duration); return new Animation(name, timelines, duration); @@ -1221,10 +1221,10 @@ namespace Spine { public string GetVersionString () { try { // try reading 4.0+ format - var initialPosition = input.Position; + long initialPosition = input.Position; ReadLong(); // long hash - var stringPosition = input.Position; + long stringPosition = input.Position; int stringByteCount = ReadInt(true); input.Position = stringPosition; if (stringByteCount <= 13) { @@ -1250,7 +1250,7 @@ namespace Spine { byteCount = ReadInt(true); if (byteCount > 1 && byteCount <= 13) { byteCount--; - var buffer = new byte[byteCount]; + byte[] buffer = new byte[byteCount]; ReadFully(buffer, 0, byteCount); return System.Text.Encoding.UTF8.GetString(buffer, 0, byteCount); } diff --git a/spine-csharp/src/SkeletonClipping.cs b/spine-csharp/src/SkeletonClipping.cs index f33304f85..ca7431a69 100644 --- a/spine-csharp/src/SkeletonClipping.cs +++ b/spine-csharp/src/SkeletonClipping.cs @@ -57,7 +57,7 @@ namespace Spine { clip.ComputeWorldVertices(slot, 0, n, vertices, 0, 2); MakeClockwise(clippingPolygon); clippingPolygons = triangulator.Decompose(clippingPolygon, triangulator.Triangulate(clippingPolygon)); - foreach (var polygon in clippingPolygons) { + foreach (ExposedList polygon in clippingPolygons) { MakeClockwise(polygon); polygon.Add(polygon.Items[0]); polygon.Add(polygon.Items[1]); @@ -80,8 +80,8 @@ namespace Spine { public void ClipTriangles (float[] vertices, int verticesLength, int[] triangles, int trianglesLength, float[] uvs) { ExposedList clipOutput = this.clipOutput, clippedVertices = this.clippedVertices; - var clippedTriangles = this.clippedTriangles; - var polygons = clippingPolygons.Items; + ExposedList clippedTriangles = this.clippedTriangles; + ExposedList[] polygons = clippingPolygons.Items; int polygonsCount = clippingPolygons.Count; int index = 0; @@ -170,8 +170,8 @@ namespace Spine { /** Clips the input triangle against the convex, clockwise clipping area. If the triangle lies entirely within the clipping * area, false is returned. The clipping area must duplicate the first vertex at the end of the vertices list. */ internal bool Clip (float x1, float y1, float x2, float y2, float x3, float y3, ExposedList clippingArea, ExposedList output) { - var originalOutput = output; - var clipped = false; + ExposedList originalOutput = output; + bool clipped = false; // Avoid copy at the end. ExposedList input = null; @@ -249,7 +249,7 @@ namespace Spine { output.Add(output.Items[1]); if (i == clippingVerticesLast) break; - var temp = output; + ExposedList temp = output; output = input; output.Clear(); input = temp; diff --git a/spine-csharp/src/SkeletonData.cs b/spine-csharp/src/SkeletonData.cs index 9039073c4..630519108 100644 --- a/spine-csharp/src/SkeletonData.cs +++ b/spine-csharp/src/SkeletonData.cs @@ -103,7 +103,7 @@ namespace Spine { /// May be null. public BoneData FindBone (string boneName) { if (boneName == null) throw new ArgumentNullException("boneName", "boneName cannot be null."); - var bones = this.bones.Items; + BoneData[] bones = this.bones.Items; for (int i = 0, n = this.bones.Count; i < n; i++) { BoneData bone = bones[i]; if (bone.name == boneName) return bone; @@ -116,7 +116,7 @@ namespace Spine { /// May be null. public SlotData FindSlot (string slotName) { if (slotName == null) throw new ArgumentNullException("slotName", "slotName cannot be null."); - var slots = this.slots.Items; + SlotData[] slots = this.slots.Items; for (int i = 0, n = this.slots.Count; i < n; i++) { SlotData slot = slots[i]; if (slot.name == slotName) return slot; @@ -149,7 +149,7 @@ namespace Spine { /// May be null. public Animation FindAnimation (string animationName) { if (animationName == null) throw new ArgumentNullException("animationName", "animationName cannot be null."); - var animations = this.animations.Items; + Animation[] animations = this.animations.Items; for (int i = 0, n = this.animations.Count; i < n; i++) { Animation animation = animations[i]; if (animation.name == animationName) return animation; @@ -162,7 +162,7 @@ namespace Spine { /// May be null. public IkConstraintData FindIkConstraint (string constraintName) { if (constraintName == null) throw new ArgumentNullException("constraintName", "constraintName cannot be null."); - var ikConstraints = this.ikConstraints.Items; + IkConstraintData[] ikConstraints = this.ikConstraints.Items; for (int i = 0, n = this.ikConstraints.Count; i < n; i++) { IkConstraintData ikConstraint = ikConstraints[i]; if (ikConstraint.name == constraintName) return ikConstraint; @@ -175,7 +175,7 @@ namespace Spine { /// May be null. public TransformConstraintData FindTransformConstraint (string constraintName) { if (constraintName == null) throw new ArgumentNullException("constraintName", "constraintName cannot be null."); - var transformConstraints = this.transformConstraints.Items; + TransformConstraintData[] transformConstraints = this.transformConstraints.Items; for (int i = 0, n = this.transformConstraints.Count; i < n; i++) { TransformConstraintData transformConstraint = transformConstraints[i]; if (transformConstraint.name == constraintName) return transformConstraint; @@ -192,7 +192,7 @@ namespace Spine { /// May be null. public PathConstraintData FindPathConstraint (string constraintName) { if (constraintName == null) throw new ArgumentNullException("constraintName", "constraintName cannot be null."); - var pathConstraints = this.pathConstraints.Items; + PathConstraintData[] pathConstraints = this.pathConstraints.Items; for (int i = 0, n = this.pathConstraints.Count; i < n; i++) { PathConstraintData constraint = pathConstraints[i]; if (constraint.name.Equals(constraintName)) return constraint; diff --git a/spine-csharp/src/SkeletonJson.cs b/spine-csharp/src/SkeletonJson.cs index 9000ee913..4b6fefc55 100644 --- a/spine-csharp/src/SkeletonJson.cs +++ b/spine-csharp/src/SkeletonJson.cs @@ -65,7 +65,7 @@ namespace Spine { private async Task ReadFile(string path) { var folder = Windows.ApplicationModel.Package.Current.InstalledLocation; var file = await folder.GetFileAsync(path).AsTask().ConfigureAwait(false); - using (var reader = new StreamReader(await file.OpenStreamForReadAsync().ConfigureAwait(false))) { + using (StreamReader reader = new StreamReader(await file.OpenStreamForReadAsync().ConfigureAwait(false))) { SkeletonData skeletonData = ReadSkeletonData(reader); skeletonData.Name = Path.GetFileNameWithoutExtension(path); return skeletonData; @@ -78,9 +78,9 @@ namespace Spine { #else public override SkeletonData ReadSkeletonData (string path) { #if WINDOWS_PHONE - using (var reader = new StreamReader(Microsoft.Xna.Framework.TitleContainer.OpenStream(path))) { + using (StreamReader reader = new StreamReader(Microsoft.Xna.Framework.TitleContainer.OpenStream(path))) { #else - using (var reader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))) { + using (StreamReader reader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))) { #endif SkeletonData skeletonData = ReadSkeletonData(reader); skeletonData.name = Path.GetFileNameWithoutExtension(path); @@ -93,14 +93,14 @@ namespace Spine { if (reader == null) throw new ArgumentNullException("reader", "reader cannot be null."); float scale = this.scale; - var skeletonData = new SkeletonData(); + SkeletonData skeletonData = new SkeletonData(); - var root = Json.Deserialize(reader) as Dictionary; + Dictionary root = Json.Deserialize(reader) as Dictionary; if (root == null) throw new Exception("Invalid JSON."); // Skeleton. if (root.ContainsKey("skeleton")) { - var skeletonMap = (Dictionary)root["skeleton"]; + Dictionary skeletonMap = (Dictionary)root["skeleton"]; skeletonData.hash = (string)skeletonMap["hash"]; skeletonData.version = (string)skeletonMap["spine"]; skeletonData.x = GetFloat(skeletonMap, "x", 0); @@ -121,7 +121,7 @@ namespace Spine { if (parent == null) throw new Exception("Parent bone not found: " + boneMap["parent"]); } - var data = new BoneData(skeletonData.Bones.Count, (string)boneMap["name"], parent); + BoneData data = new BoneData(skeletonData.Bones.Count, (string)boneMap["name"], parent); data.length = GetFloat(boneMap, "length", 0) * scale; data.x = GetFloat(boneMap, "x", 0) * scale; data.y = GetFloat(boneMap, "y", 0) * scale; @@ -142,11 +142,11 @@ namespace Spine { // Slots. if (root.ContainsKey("slots")) { foreach (Dictionary slotMap in (List)root["slots"]) { - var slotName = (string)slotMap["name"]; - var boneName = (string)slotMap["bone"]; + string slotName = (string)slotMap["name"]; + string boneName = (string)slotMap["bone"]; BoneData boneData = skeletonData.FindBone(boneName); if (boneData == null) throw new Exception("Slot bone not found: " + boneName); - var data = new SlotData(skeletonData.Slots.Count, slotName, boneData); + SlotData data = new SlotData(skeletonData.Slots.Count, slotName, boneData); if (slotMap.ContainsKey("color")) { string color = (string)slotMap["color"]; @@ -157,7 +157,7 @@ namespace Spine { } if (slotMap.ContainsKey("dark")) { - var color2 = (string)slotMap["dark"]; + string color2 = (string)slotMap["dark"]; data.r2 = ToColor(color2, 0, 6); // expectedLength = 6. ie. "RRGGBB" data.g2 = ToColor(color2, 1, 6); data.b2 = ToColor(color2, 2, 6); @@ -345,8 +345,8 @@ namespace Spine { // Events. if (root.ContainsKey("events")) { foreach (KeyValuePair entry in (Dictionary)root["events"]) { - var entryMap = (Dictionary)entry.Value; - var data = new EventData(entry.Key); + Dictionary entryMap = (Dictionary)entry.Value; + EventData data = new EventData(entry.Key); data.Int = GetInt(entryMap, "int", 0); data.Float = GetFloat(entryMap, "float", 0); data.String = GetString(entryMap, "string", string.Empty); @@ -383,8 +383,8 @@ namespace Spine { float scale = this.scale; name = GetString(map, "name", name); - var typeName = GetString(map, "type", "region"); - var type = (AttachmentType)Enum.Parse(typeof(AttachmentType), typeName, true); + string typeName = GetString(map, "type", "region"); + AttachmentType type = (AttachmentType)Enum.Parse(typeof(AttachmentType), typeName, true); switch (type) { case AttachmentType.Region: { @@ -405,7 +405,7 @@ namespace Spine { region.sequence = sequence; if (map.ContainsKey("color")) { - var color = (string)map["color"]; + string color = (string)map["color"]; region.r = ToColor(color, 0); region.g = ToColor(color, 1); region.b = ToColor(color, 2); @@ -431,7 +431,7 @@ namespace Spine { mesh.Path = path; if (map.ContainsKey("color")) { - var color = (string)map["color"]; + string color = (string)map["color"]; mesh.r = ToColor(color, 0); mesh.g = ToColor(color, 1); mesh.b = ToColor(color, 2); @@ -504,7 +504,7 @@ namespace Spine { } public static Sequence ReadSequence (object sequenceJson) { - var map = sequenceJson as Dictionary; + Dictionary map = sequenceJson as Dictionary; if (map == null) return null; Sequence sequence = new Sequence(GetInt(map, "count")); sequence.start = GetInt(map, "start", 1); @@ -550,22 +550,22 @@ namespace Spine { } private void ReadAnimation (Dictionary map, string name, SkeletonData skeletonData) { - var scale = this.scale; - var timelines = new ExposedList(); + float scale = this.scale; + ExposedList timelines = new ExposedList(); // Slot timelines. if (map.ContainsKey("slots")) { foreach (KeyValuePair entry in (Dictionary)map["slots"]) { string slotName = entry.Key; int slotIndex = FindSlotIndex(skeletonData, slotName); - var timelineMap = (Dictionary)entry.Value; + Dictionary timelineMap = (Dictionary)entry.Value; foreach (KeyValuePair timelineEntry in timelineMap) { - var values = (List)timelineEntry.Value; + List values = (List)timelineEntry.Value; int frames = values.Count; if (frames == 0) continue; - var timelineName = (string)timelineEntry.Key; + string timelineName = (string)timelineEntry.Key; if (timelineName == "attachment") { - var timeline = new AttachmentTimeline(frames, slotIndex); + AttachmentTimeline timeline = new AttachmentTimeline(frames, slotIndex); int frame = 0; foreach (Dictionary keyMap in values) { timeline.SetFrame(frame++, GetFloat(keyMap, "time", 0), GetString(keyMap, "name", null)); @@ -573,11 +573,11 @@ namespace Spine { timelines.Add(timeline); } else if (timelineName == "rgba") { - var timeline = new RGBATimeline(frames, frames << 2, slotIndex); + RGBATimeline timeline = new RGBATimeline(frames, frames << 2, slotIndex); - var keyMapEnumerator = values.GetEnumerator(); + List.Enumerator keyMapEnumerator = values.GetEnumerator(); keyMapEnumerator.MoveNext(); - var keyMap = (Dictionary)keyMapEnumerator.Current; + Dictionary keyMap = (Dictionary)keyMapEnumerator.Current; float time = GetFloat(keyMap, "time", 0); string color = (string)keyMap["color"]; float r = ToColor(color, 0); @@ -590,7 +590,7 @@ namespace Spine { timeline.Shrink(bezier); break; } - var nextMap = (Dictionary)keyMapEnumerator.Current; + Dictionary nextMap = (Dictionary)keyMapEnumerator.Current; float time2 = GetFloat(nextMap, "time", 0); color = (string)nextMap["color"]; @@ -616,11 +616,11 @@ namespace Spine { timelines.Add(timeline); } else if (timelineName == "rgb") { - var timeline = new RGBTimeline(frames, frames * 3, slotIndex); + RGBTimeline timeline = new RGBTimeline(frames, frames * 3, slotIndex); - var keyMapEnumerator = values.GetEnumerator(); + List.Enumerator keyMapEnumerator = values.GetEnumerator(); keyMapEnumerator.MoveNext(); - var keyMap = (Dictionary)keyMapEnumerator.Current; + Dictionary keyMap = (Dictionary)keyMapEnumerator.Current; float time = GetFloat(keyMap, "time", 0); string color = (string)keyMap["color"]; float r = ToColor(color, 0, 6); @@ -632,7 +632,7 @@ namespace Spine { timeline.Shrink(bezier); break; } - var nextMap = (Dictionary)keyMapEnumerator.Current; + Dictionary nextMap = (Dictionary)keyMapEnumerator.Current; float time2 = GetFloat(nextMap, "time", 0); color = (string)nextMap["color"]; @@ -655,16 +655,16 @@ namespace Spine { timelines.Add(timeline); } else if (timelineName == "alpha") { - var keyMapEnumerator = values.GetEnumerator(); + List.Enumerator keyMapEnumerator = values.GetEnumerator(); keyMapEnumerator.MoveNext(); timelines.Add(ReadTimeline(ref keyMapEnumerator, new AlphaTimeline(frames, frames, slotIndex), 0, 1)); } else if (timelineName == "rgba2") { - var timeline = new RGBA2Timeline(frames, frames * 7, slotIndex); + RGBA2Timeline timeline = new RGBA2Timeline(frames, frames * 7, slotIndex); - var keyMapEnumerator = values.GetEnumerator(); + List.Enumerator keyMapEnumerator = values.GetEnumerator(); keyMapEnumerator.MoveNext(); - var keyMap = (Dictionary)keyMapEnumerator.Current; + Dictionary keyMap = (Dictionary)keyMapEnumerator.Current; float time = GetFloat(keyMap, "time", 0); string color = (string)keyMap["light"]; float r = ToColor(color, 0); @@ -681,7 +681,7 @@ namespace Spine { timeline.Shrink(bezier); break; } - var nextMap = (Dictionary)keyMapEnumerator.Current; + Dictionary nextMap = (Dictionary)keyMapEnumerator.Current; float time2 = GetFloat(nextMap, "time", 0); color = (string)nextMap["light"]; @@ -717,11 +717,11 @@ namespace Spine { timelines.Add(timeline); } else if (timelineName == "rgb2") { - var timeline = new RGB2Timeline(frames, frames * 6, slotIndex); + RGB2Timeline timeline = new RGB2Timeline(frames, frames * 6, slotIndex); - var keyMapEnumerator = values.GetEnumerator(); + List.Enumerator keyMapEnumerator = values.GetEnumerator(); keyMapEnumerator.MoveNext(); - var keyMap = (Dictionary)keyMapEnumerator.Current; + Dictionary keyMap = (Dictionary)keyMapEnumerator.Current; float time = GetFloat(keyMap, "time", 0); string color = (string)keyMap["light"]; float r = ToColor(color, 0, 6); @@ -737,7 +737,7 @@ namespace Spine { timeline.Shrink(bezier); break; } - var nextMap = (Dictionary)keyMapEnumerator.Current; + Dictionary nextMap = (Dictionary)keyMapEnumerator.Current; float time2 = GetFloat(nextMap, "time", 0); color = (string)nextMap["light"]; @@ -780,7 +780,7 @@ namespace Spine { foreach (KeyValuePair entry in (Dictionary)map["bones"]) { string boneName = entry.Key; int boneIndex = -1; - var bones = skeletonData.bones.Items; + BoneData[] bones = skeletonData.bones.Items; for (int i = 0, n = skeletonData.bones.Count; i < n; i++) { if (bones[i].name == boneName) { boneIndex = i; @@ -788,13 +788,13 @@ namespace Spine { } } if (boneIndex == -1) throw new Exception("Bone not found: " + boneName); - var timelineMap = (Dictionary)entry.Value; + Dictionary timelineMap = (Dictionary)entry.Value; foreach (KeyValuePair timelineEntry in timelineMap) { - var values = (List)timelineEntry.Value; - var keyMapEnumerator = values.GetEnumerator(); + List values = (List)timelineEntry.Value; + List.Enumerator keyMapEnumerator = values.GetEnumerator(); if (!keyMapEnumerator.MoveNext()) continue; int frames = values.Count; - var timelineName = (string)timelineEntry.Key; + string timelineName = (string)timelineEntry.Key; if (timelineName == "rotate") timelines.Add(ReadTimeline(ref keyMapEnumerator, new RotateTimeline(frames, frames, boneIndex), 0, 1)); else if (timelineName == "translate") { @@ -829,10 +829,10 @@ namespace Spine { // IK constraint timelines. if (map.ContainsKey("ik")) { foreach (KeyValuePair timelineMap in (Dictionary)map["ik"]) { - var values = (List)timelineMap.Value; - var keyMapEnumerator = values.GetEnumerator(); + List values = (List)timelineMap.Value; + List.Enumerator keyMapEnumerator = values.GetEnumerator(); if (!keyMapEnumerator.MoveNext()) continue; - var keyMap = (Dictionary)keyMapEnumerator.Current; + Dictionary keyMap = (Dictionary)keyMapEnumerator.Current; IkConstraintData constraint = skeletonData.FindIkConstraint(timelineMap.Key); IkConstraintTimeline timeline = new IkConstraintTimeline(values.Count, values.Count << 1, skeletonData.IkConstraints.IndexOf(constraint)); @@ -845,7 +845,7 @@ namespace Spine { timeline.Shrink(bezier); break; } - var nextMap = (Dictionary)keyMapEnumerator.Current; + Dictionary nextMap = (Dictionary)keyMapEnumerator.Current; float time2 = GetFloat(nextMap, "time", 0); float mix2 = GetFloat(nextMap, "mix", 1), softness2 = GetFloat(nextMap, "softness", 0) * scale; if (keyMap.ContainsKey("curve")) { @@ -865,10 +865,10 @@ namespace Spine { // Transform constraint timelines. if (map.ContainsKey("transform")) { foreach (KeyValuePair timelineMap in (Dictionary)map["transform"]) { - var values = (List)timelineMap.Value; - var keyMapEnumerator = values.GetEnumerator(); + List values = (List)timelineMap.Value; + List.Enumerator keyMapEnumerator = values.GetEnumerator(); if (!keyMapEnumerator.MoveNext()) continue; - var keyMap = (Dictionary)keyMapEnumerator.Current; + Dictionary keyMap = (Dictionary)keyMapEnumerator.Current; TransformConstraintData constraint = skeletonData.FindTransformConstraint(timelineMap.Key); TransformConstraintTimeline timeline = new TransformConstraintTimeline(values.Count, values.Count * 6, skeletonData.TransformConstraints.IndexOf(constraint)); @@ -882,7 +882,7 @@ namespace Spine { timeline.Shrink(bezier); break; } - var nextMap = (Dictionary)keyMapEnumerator.Current; + Dictionary nextMap = (Dictionary)keyMapEnumerator.Current; float time2 = GetFloat(nextMap, "time", 0); float mixRotate2 = GetFloat(nextMap, "mixRotate", 1), mixShearY2 = GetFloat(nextMap, "mixShearY", 1); float mixX2 = GetFloat(nextMap, "mixX", 1), mixY2 = GetFloat(nextMap, "mixY", mixX2); @@ -915,14 +915,14 @@ namespace Spine { PathConstraintData constraint = skeletonData.FindPathConstraint(constraintMap.Key); if (constraint == null) throw new Exception("Path constraint not found: " + constraintMap.Key); int constraintIndex = skeletonData.pathConstraints.IndexOf(constraint); - var timelineMap = (Dictionary)constraintMap.Value; + Dictionary timelineMap = (Dictionary)constraintMap.Value; foreach (KeyValuePair timelineEntry in timelineMap) { - var values = (List)timelineEntry.Value; - var keyMapEnumerator = values.GetEnumerator(); + List values = (List)timelineEntry.Value; + List.Enumerator keyMapEnumerator = values.GetEnumerator(); if (!keyMapEnumerator.MoveNext()) continue; int frames = values.Count; - var timelineName = (string)timelineEntry.Key; + string timelineName = (string)timelineEntry.Key; if (timelineName == "position") { CurveTimeline1 timeline = new PathConstraintPositionTimeline(frames, frames, constraintIndex); timelines.Add(ReadTimeline(ref keyMapEnumerator, timeline, 0, constraint.positionMode == PositionMode.Fixed ? scale : 1)); @@ -932,7 +932,7 @@ namespace Spine { constraint.spacingMode == SpacingMode.Length || constraint.spacingMode == SpacingMode.Fixed ? scale : 1)); } else if (timelineName == "mix") { PathConstraintMixTimeline timeline = new PathConstraintMixTimeline(frames, frames * 3, constraintIndex); - var keyMap = (Dictionary)keyMapEnumerator.Current; + Dictionary keyMap = (Dictionary)keyMapEnumerator.Current; float time = GetFloat(keyMap, "time", 0); float mixRotate = GetFloat(keyMap, "mixRotate", 1); float mixX = GetFloat(keyMap, "mixX", 1), mixY = GetFloat(keyMap, "mixY", mixX); @@ -942,7 +942,7 @@ namespace Spine { timeline.Shrink(bezier); break; } - var nextMap = (Dictionary)keyMapEnumerator.Current; + Dictionary nextMap = (Dictionary)keyMapEnumerator.Current; float time2 = GetFloat(nextMap, "time", 0); float mixRotate2 = GetFloat(nextMap, "mixRotate", 1); float mixX2 = GetFloat(nextMap, "mixX", 1), mixY2 = GetFloat(nextMap, "mixY", mixX2); @@ -975,10 +975,10 @@ namespace Spine { Attachment attachment = skin.GetAttachment(slot.index, attachmentMap.Key); if (attachment == null) throw new Exception("Timeline attachment not found: " + attachmentMap.Key); foreach (KeyValuePair timelineMap in (Dictionary)attachmentMap.Value) { - var values = (List)timelineMap.Value; - var keyMapEnumerator = values.GetEnumerator(); + List values = (List)timelineMap.Value; + List.Enumerator keyMapEnumerator = values.GetEnumerator(); if (!keyMapEnumerator.MoveNext()) continue; - var keyMap = (Dictionary)keyMapEnumerator.Current; + Dictionary keyMap = (Dictionary)keyMapEnumerator.Current; int frames = values.Count; string timelineName = timelineMap.Key; if (timelineName == "deform") { @@ -1014,7 +1014,7 @@ namespace Spine { timeline.Shrink(bezier); break; } - var nextMap = (Dictionary)keyMapEnumerator.Current; + Dictionary nextMap = (Dictionary)keyMapEnumerator.Current; float time2 = GetFloat(nextMap, "time", 0); if (keyMap.ContainsKey("curve")) { object curve = keyMap["curve"]; @@ -1047,8 +1047,8 @@ namespace Spine { // Draw order timeline. if (map.ContainsKey("drawOrder")) { - var values = (List)map["drawOrder"]; - var timeline = new DrawOrderTimeline(values.Count); + List values = (List)map["drawOrder"]; + DrawOrderTimeline timeline = new DrawOrderTimeline(values.Count); int slotCount = skeletonData.slots.Count; int frame = 0; foreach (Dictionary drawOrderMap in values) { @@ -1057,7 +1057,7 @@ namespace Spine { drawOrder = new int[slotCount]; for (int i = slotCount - 1; i >= 0; i--) drawOrder[i] = -1; - var offsets = (List)drawOrderMap["offsets"]; + List offsets = (List)drawOrderMap["offsets"]; int[] unchanged = new int[slotCount - offsets.Count]; int originalIndex = 0, unchangedIndex = 0; foreach (Dictionary offsetMap in offsets) { @@ -1084,13 +1084,13 @@ namespace Spine { // Event timeline. if (map.ContainsKey("events")) { - var eventsMap = (List)map["events"]; - var timeline = new EventTimeline(eventsMap.Count); + List eventsMap = (List)map["events"]; + EventTimeline timeline = new EventTimeline(eventsMap.Count); int frame = 0; foreach (Dictionary eventMap in eventsMap) { EventData eventData = skeletonData.FindEvent((string)eventMap["name"]); if (eventData == null) throw new Exception("Event not found: " + eventMap["name"]); - var e = new Event(GetFloat(eventMap, "time", 0), eventData) { + Event e = new Event(GetFloat(eventMap, "time", 0), eventData) { intValue = GetInt(eventMap, "int", eventData.Int), floatValue = GetFloat(eventMap, "float", eventData.Float), stringValue = GetString(eventMap, "string", eventData.String) @@ -1106,14 +1106,14 @@ namespace Spine { } timelines.TrimExcess(); float duration = 0; - var items = timelines.Items; + Timeline[] items = timelines.Items; for (int i = 0, n = timelines.Count; i < n; i++) duration = Math.Max(duration, items[i].Duration); skeletonData.animations.Add(new Animation(name, timelines, duration)); } static Timeline ReadTimeline (ref List.Enumerator keyMapEnumerator, CurveTimeline1 timeline, float defaultValue, float scale) { - var keyMap = (Dictionary)keyMapEnumerator.Current; + Dictionary keyMap = (Dictionary)keyMapEnumerator.Current; float time = GetFloat(keyMap, "time", 0); float value = GetFloat(keyMap, "value", defaultValue) * scale; for (int frame = 0, bezier = 0; ; frame++) { @@ -1122,7 +1122,7 @@ namespace Spine { timeline.Shrink(bezier); return timeline; } - var nextMap = (Dictionary)keyMapEnumerator.Current; + Dictionary nextMap = (Dictionary)keyMapEnumerator.Current; float time2 = GetFloat(nextMap, "time", 0); float value2 = GetFloat(nextMap, "value", defaultValue) * scale; if (keyMap.ContainsKey("curve")) { @@ -1138,7 +1138,7 @@ namespace Spine { static Timeline ReadTimeline (ref List.Enumerator keyMapEnumerator, CurveTimeline2 timeline, String name1, String name2, float defaultValue, float scale) { - var keyMap = (Dictionary)keyMapEnumerator.Current; + Dictionary keyMap = (Dictionary)keyMapEnumerator.Current; float time = GetFloat(keyMap, "time", 0); float value1 = GetFloat(keyMap, name1, defaultValue) * scale, value2 = GetFloat(keyMap, name2, defaultValue) * scale; for (int frame = 0, bezier = 0; ; frame++) { @@ -1147,7 +1147,7 @@ namespace Spine { timeline.Shrink(bezier); return timeline; } - var nextMap = (Dictionary)keyMapEnumerator.Current; + Dictionary nextMap = (Dictionary)keyMapEnumerator.Current; float time2 = GetFloat(nextMap, "time", 0); float nvalue1 = GetFloat(nextMap, name1, defaultValue) * scale, nvalue2 = GetFloat(nextMap, name2, defaultValue) * scale; if (keyMap.ContainsKey("curve")) { @@ -1170,7 +1170,7 @@ namespace Spine { if (curveString == "stepped") timeline.SetStepped(frame); return bezier; } - var curveValues = (List)curve; + List curveValues = (List)curve; int i = value << 2; float cx1 = (float)curveValues[i]; float cy1 = (float)curveValues[i + 1] * scale; @@ -1186,8 +1186,8 @@ namespace Spine { } static float[] GetFloatArray (Dictionary map, string name, float scale) { - var list = (List)map[name]; - var values = new float[list.Count]; + List list = (List)map[name]; + float[] values = new float[list.Count]; if (scale == 1) { for (int i = 0, n = list.Count; i < n; i++) values[i] = (float)list[i]; @@ -1199,8 +1199,8 @@ namespace Spine { } static int[] GetIntArray (Dictionary map, string name) { - var list = (List)map[name]; - var values = new int[list.Count]; + List list = (List)map[name]; + int[] values = new int[list.Count]; for (int i = 0, n = list.Count; i < n; i++) values[i] = (int)(float)list[i]; return values; diff --git a/spine-csharp/src/Skin.cs b/spine-csharp/src/Skin.cs index ff67d6368..884ed2829 100644 --- a/spine-csharp/src/Skin.cs +++ b/spine-csharp/src/Skin.cs @@ -70,7 +70,7 @@ namespace Spine { foreach (ConstraintData data in skin.constraints) if (!constraints.Contains(data)) constraints.Add(data); - foreach (var item in skin.attachments) { + foreach (KeyValuePair item in skin.attachments) { SkinEntry entry = item.Value; SetAttachment(entry.slotIndex, entry.name, entry.attachment); } @@ -84,7 +84,7 @@ namespace Spine { foreach (ConstraintData data in skin.constraints) if (!constraints.Contains(data)) constraints.Add(data); - foreach (var item in skin.attachments) { + foreach (KeyValuePair item in skin.attachments) { SkinEntry entry = item.Value; if (entry.attachment is MeshAttachment) { SetAttachment(entry.slotIndex, entry.name, @@ -112,7 +112,7 @@ namespace Spine { public void GetAttachments (int slotIndex, List attachments) { if (slotIndex < 0) throw new ArgumentException("slotIndex must be >= 0."); if (attachments == null) throw new ArgumentNullException("attachments", "attachments cannot be null."); - foreach (var item in this.attachments) { + foreach (KeyValuePair item in this.attachments) { SkinEntry entry = item.Value; if (entry.slotIndex == slotIndex) attachments.Add(entry); } @@ -132,7 +132,7 @@ namespace Spine { /// Attach all attachments from this skin if the corresponding attachment from the old skin is currently attached. internal void AttachAll (Skeleton skeleton, Skin oldSkin) { Slot[] slots = skeleton.slots.Items; - foreach (var item in oldSkin.attachments) { + foreach (KeyValuePair item in oldSkin.attachments) { SkinEntry entry = item.Value; int slotIndex = entry.slotIndex; Slot slot = slots[slotIndex]; diff --git a/spine-csharp/src/TransformConstraint.cs b/spine-csharp/src/TransformConstraint.cs index 594ca7799..83cf25098 100644 --- a/spine-csharp/src/TransformConstraint.cs +++ b/spine-csharp/src/TransformConstraint.cs @@ -104,7 +104,7 @@ namespace Spine { float degRadReflect = ta * td - tb * tc > 0 ? MathUtils.DegRad : -MathUtils.DegRad; float offsetRotation = data.offsetRotation * degRadReflect, offsetShearY = data.offsetShearY * degRadReflect; - var bones = this.bones.Items; + Bone[] bones = this.bones.Items; for (int i = 0, n = this.bones.Count; i < n; i++) { Bone bone = bones[i]; @@ -171,7 +171,7 @@ namespace Spine { float degRadReflect = ta * td - tb * tc > 0 ? MathUtils.DegRad : -MathUtils.DegRad; float offsetRotation = data.offsetRotation * degRadReflect, offsetShearY = data.offsetShearY * degRadReflect; - var bones = this.bones.Items; + Bone[] bones = this.bones.Items; for (int i = 0, n = this.bones.Count; i < n; i++) { Bone bone = bones[i]; @@ -231,7 +231,7 @@ namespace Spine { Bone target = this.target; - var bones = this.bones.Items; + Bone[] bones = this.bones.Items; for (int i = 0, n = this.bones.Count; i < n; i++) { Bone bone = bones[i]; @@ -269,7 +269,7 @@ namespace Spine { Bone target = this.target; - var bones = this.bones.Items; + Bone[] bones = this.bones.Items; for (int i = 0, n = this.bones.Count; i < n; i++) { Bone bone = bones[i]; diff --git a/spine-csharp/src/Triangulator.cs b/spine-csharp/src/Triangulator.cs index 61b68024a..6b3bf158c 100644 --- a/spine-csharp/src/Triangulator.cs +++ b/spine-csharp/src/Triangulator.cs @@ -42,21 +42,21 @@ namespace Spine { private readonly Pool> polygonIndicesPool = new Pool>(); public ExposedList Triangulate (ExposedList verticesArray) { - var vertices = verticesArray.Items; + float[] vertices = verticesArray.Items; int vertexCount = verticesArray.Count >> 1; - var indicesArray = this.indicesArray; + ExposedList indicesArray = this.indicesArray; indicesArray.Clear(); int[] indices = indicesArray.Resize(vertexCount).Items; for (int i = 0; i < vertexCount; i++) indices[i] = i; - var isConcaveArray = this.isConcaveArray; + ExposedList isConcaveArray = this.isConcaveArray; bool[] isConcave = isConcaveArray.Resize(vertexCount).Items; for (int i = 0, n = vertexCount; i < n; ++i) isConcave[i] = IsConcave(i, vertexCount, vertices, indices); - var triangles = this.triangles; + ExposedList triangles = this.triangles; triangles.Clear(); triangles.EnsureCapacity(Math.Max(0, vertexCount - 2) << 2); @@ -122,21 +122,21 @@ namespace Spine { } public ExposedList> Decompose (ExposedList verticesArray, ExposedList triangles) { - var vertices = verticesArray.Items; - var convexPolygons = this.convexPolygons; + float[] vertices = verticesArray.Items; + ExposedList> convexPolygons = this.convexPolygons; for (int i = 0, n = convexPolygons.Count; i < n; i++) polygonPool.Free(convexPolygons.Items[i]); convexPolygons.Clear(); - var convexPolygonsIndices = this.convexPolygonsIndices; + ExposedList> convexPolygonsIndices = this.convexPolygonsIndices; for (int i = 0, n = convexPolygonsIndices.Count; i < n; i++) polygonIndicesPool.Free(convexPolygonsIndices.Items[i]); convexPolygonsIndices.Clear(); - var polygonIndices = polygonIndicesPool.Obtain(); + ExposedList polygonIndices = polygonIndicesPool.Obtain(); polygonIndices.Clear(); - var polygon = polygonPool.Obtain(); + ExposedList polygon = polygonPool.Obtain(); polygon.Clear(); // Merge subsequent triangles if they form a triangle fan. @@ -149,7 +149,7 @@ namespace Spine { float x3 = vertices[t3], y3 = vertices[t3 + 1]; // If the base of the last triangle is the same as this triangle, check if they form a convex polygon (triangle fan). - var merged = false; + bool merged = false; if (fanBaseIndex == t1) { int o = polygon.Count - 4; float[] p = polygon.Items; @@ -213,13 +213,13 @@ namespace Spine { for (int ii = 0; ii < n; ii++) { if (ii == i) continue; - var otherIndices = convexPolygonsIndices.Items[ii]; + ExposedList otherIndices = convexPolygonsIndices.Items[ii]; if (otherIndices.Count != 3) continue; int otherFirstIndex = otherIndices.Items[0]; int otherSecondIndex = otherIndices.Items[1]; int otherLastIndex = otherIndices.Items[2]; - var otherPoly = convexPolygons.Items[ii]; + ExposedList otherPoly = convexPolygons.Items[ii]; float x3 = otherPoly.Items[otherPoly.Count - 2], y3 = otherPoly.Items[otherPoly.Count - 1]; if (otherFirstIndex != firstIndex || otherSecondIndex != lastIndex) continue; diff --git a/spine-csharp/tests/src/AnimationStateTests.cs b/spine-csharp/tests/src/AnimationStateTests.cs index b338bd770..0bb06e631 100644 --- a/spine-csharp/tests/src/AnimationStateTests.cs +++ b/spine-csharp/tests/src/AnimationStateTests.cs @@ -821,7 +821,7 @@ namespace Spine { Expect(1, "dispose", 1, 2.1f) // ); state.SetAnimation(0, "events0", false); - var entry1 = state.AddAnimation(0, "events1", false, 0); + TrackEntry entry1 = state.AddAnimation(0, "events1", false, 0); entry1.MixDuration = 0.25f; entry1.TrackEnd = 1.0f; Run(0.1f, 1000, null); diff --git a/spine-unity/Assets/Spine Examples/Other Examples/Animation Tester/SpineAnimationTesterTool.cs b/spine-unity/Assets/Spine Examples/Other Examples/Animation Tester/SpineAnimationTesterTool.cs index 6e18ca7cf..4ce80557d 100644 --- a/spine-unity/Assets/Spine Examples/Other Examples/Animation Tester/SpineAnimationTesterTool.cs +++ b/spine-unity/Assets/Spine Examples/Other Examples/Animation Tester/SpineAnimationTesterTool.cs @@ -88,7 +88,7 @@ namespace Spine.Unity.Examples { // Fill in the control list. if (boundAnimationsText != null) { - var boundAnimationsStringBuilder = new StringBuilder(); + StringBuilder boundAnimationsStringBuilder = new StringBuilder(); boundAnimationsStringBuilder.AppendLine("Animation Controls:"); for (int trackIndex = 0; trackIndex < trackControls.Count; trackIndex++) { @@ -97,7 +97,7 @@ namespace Spine.Unity.Examples { boundAnimationsStringBuilder.AppendLine(); boundAnimationsStringBuilder.AppendFormat("---- Track {0} ---- \n", trackIndex); - foreach (var ba in trackControls[trackIndex].controls) { + foreach (AnimationControl ba in trackControls[trackIndex].controls) { string animationName = ba.animationName; if (string.IsNullOrEmpty(animationName)) animationName = "SetEmptyAnimation"; @@ -120,13 +120,13 @@ namespace Spine.Unity.Examples { } void Update () { - var animationState = skeletonAnimation.AnimationState; + AnimationState animationState = skeletonAnimation.AnimationState; // For each track for (int trackIndex = 0; trackIndex < trackControls.Count; trackIndex++) { // For each control in the track - foreach (var control in trackControls[trackIndex].controls) { + foreach (AnimationControl control in trackControls[trackIndex].controls) { // Check each control, and play the appropriate animation. if (Input.GetKeyDown(control.key)) { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineBlinkPlayer.cs b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineBlinkPlayer.cs index c1a19b3a9..93ec7dd6d 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineBlinkPlayer.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineBlinkPlayer.cs @@ -40,7 +40,8 @@ namespace Spine.Unity.Examples { public float maximumDelay = 3f; IEnumerator Start () { - var skeletonAnimation = GetComponent(); if (skeletonAnimation == null) yield break; + SkeletonAnimation skeletonAnimation = GetComponent(); + if (skeletonAnimation == null) yield break; while (true) { skeletonAnimation.AnimationState.SetAnimation(SpineBlinkPlayer.BlinkTrack, blinkAnimation, false); yield return new WaitForSeconds(Random.Range(minimumDelay, maximumDelay)); diff --git a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerModel.cs b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerModel.cs index 387b5a684..f50ae5107 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerModel.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerModel.cs @@ -94,7 +94,7 @@ namespace Spine.Unity.Examples { // Fake jumping. { - var pos = transform.localPosition; + Vector3 pos = transform.localPosition; const float jumpTime = 1.2f; const float half = jumpTime * 0.5f; const float jumpPower = 20f; diff --git a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs index 0c0e61fcc..486d5850b 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs @@ -75,7 +75,7 @@ namespace Spine.Unity.Examples { } // Detect changes in model.state - var currentModelState = model.state; + SpineBeginnerBodyState currentModelState = model.state; if (previousViewState != currentModelState) { PlayNewStableAnimation(); @@ -85,7 +85,7 @@ namespace Spine.Unity.Examples { } void PlayNewStableAnimation () { - var newModelState = model.state; + SpineBeginnerBodyState newModelState = model.state; Animation nextAnimation; // Add conditionals to not interrupt transient animations. @@ -115,7 +115,7 @@ namespace Spine.Unity.Examples { [ContextMenu("Check Tracks")] void CheckTracks () { - var state = skeletonAnimation.AnimationState; + AnimationState state = skeletonAnimation.AnimationState; Debug.Log(state.GetCurrent(0)); Debug.Log(state.GetCurrent(1)); } @@ -123,13 +123,13 @@ namespace Spine.Unity.Examples { #region Transient Actions public void PlayShoot () { // Play the shoot animation on track 1. - var shootTrack = skeletonAnimation.AnimationState.SetAnimation(1, shoot, false); + TrackEntry shootTrack = skeletonAnimation.AnimationState.SetAnimation(1, shoot, false); shootTrack.AttachmentThreshold = 1f; shootTrack.MixDuration = 0f; skeletonAnimation.state.AddEmptyAnimation(1, 0.5f, 0.1f); // Play the aim animation on track 2 to aim at the mouse target. - var aimTrack = skeletonAnimation.AnimationState.SetAnimation(2, aim, false); + TrackEntry aimTrack = skeletonAnimation.AnimationState.SetAnimation(2, aim, false); aimTrack.AttachmentThreshold = 1f; aimTrack.MixDuration = 0f; skeletonAnimation.state.AddEmptyAnimation(2, 0.5f, 0.1f); @@ -142,7 +142,7 @@ namespace Spine.Unity.Examples { public void StartPlayingAim () { // Play the aim animation on track 2 to aim at the mouse target. - var aimTrack = skeletonAnimation.AnimationState.SetAnimation(2, aim, true); + TrackEntry aimTrack = skeletonAnimation.AnimationState.SetAnimation(2, aim, true); aimTrack.AttachmentThreshold = 1f; aimTrack.MixDuration = 0f; } diff --git a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs index 3ddedda02..45b690b63 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs @@ -49,9 +49,9 @@ namespace Spine.Unity.Examples { } void Update () { - var mousePosition = Input.mousePosition; - var worldMousePosition = cam.ScreenToWorldPoint(mousePosition); - var skeletonSpacePoint = skeletonAnimation.transform.InverseTransformPoint(worldMousePosition); + Vector3 mousePosition = Input.mousePosition; + Vector3 worldMousePosition = cam.ScreenToWorldPoint(mousePosition); + Vector3 skeletonSpacePoint = skeletonAnimation.transform.InverseTransformPoint(worldMousePosition); skeletonSpacePoint.x *= skeletonAnimation.Skeleton.ScaleX; skeletonSpacePoint.y *= skeletonAnimation.Skeleton.ScaleY; bone.SetLocalPosition(skeletonSpacePoint); diff --git a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/TransitionDictionaryExample.cs b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/TransitionDictionaryExample.cs index 61122b0df..3e618490b 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/TransitionDictionaryExample.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/TransitionDictionaryExample.cs @@ -50,7 +50,7 @@ namespace Spine.Unity.Examples { void Start () { dictionary.Clear(); - foreach (var e in transitions) { + foreach (SerializedEntry e in transitions) { dictionary.Add(new AnimationStateData.AnimationPair(e.from.Animation, e.to.Animation), e.transition.Animation); } } diff --git a/spine-unity/Assets/Spine Examples/Scripts/HurtFlashEffect.cs b/spine-unity/Assets/Spine Examples/Scripts/HurtFlashEffect.cs index 98c988171..48ad33317 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/HurtFlashEffect.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/HurtFlashEffect.cs @@ -58,7 +58,7 @@ public class HurtFlashEffect : MonoBehaviour { int fillPhase = Shader.PropertyToID(fillPhaseProperty); int fillColor = Shader.PropertyToID(fillColorProperty); - var wait = new WaitForSeconds(interval); + WaitForSeconds wait = new WaitForSeconds(interval); for (int i = 0; i < flashCount; i++) { mpb.SetColor(fillColor, flashColor); diff --git a/spine-unity/Assets/Spine Examples/Scripts/Mecanim as Logic/SkeletonAnimationHandleExample.cs b/spine-unity/Assets/Spine Examples/Scripts/Mecanim as Logic/SkeletonAnimationHandleExample.cs index f36221a35..16fe06108 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Mecanim as Logic/SkeletonAnimationHandleExample.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Mecanim as Logic/SkeletonAnimationHandleExample.cs @@ -61,17 +61,17 @@ namespace Spine.Unity.Examples { void Awake () { // Initialize AnimationReferenceAssets - foreach (var entry in statesAndAnimations) { + foreach (StateNameToAnimationReference entry in statesAndAnimations) { entry.animation.Initialize(); } - foreach (var entry in transitions) { + foreach (AnimationTransition entry in transitions) { entry.from.Initialize(); entry.to.Initialize(); entry.transition.Initialize(); } // Build Dictionary - //foreach (var entry in transitions) { + //foreach (AnimationTransition entry in transitions) { // transitionDictionary.Add(new AnimationStateData.AnimationPair(entry.from.Animation, entry.to.Animation), entry.transition.Animation); //} } @@ -90,7 +90,7 @@ namespace Spine.Unity.Examples { /// Plays an animation based on the hash of the state name. public void PlayAnimationForState (int shortNameHash, int layerIndex) { - var foundAnimation = GetAnimationForState(shortNameHash); + Animation foundAnimation = GetAnimationForState(shortNameHash); if (foundAnimation == null) return; @@ -104,7 +104,7 @@ namespace Spine.Unity.Examples { /// Gets a Spine Animation based on the hash of the state name. public Spine.Animation GetAnimationForState (int shortNameHash) { - var foundState = statesAndAnimations.Find(entry => StringToHash(entry.stateName) == shortNameHash); + StateNameToAnimationReference foundState = statesAndAnimations.Find(entry => StringToHash(entry.stateName) == shortNameHash); return (foundState == null) ? null : foundState.animation; } @@ -129,10 +129,10 @@ namespace Spine.Unity.Examples { /// Play a non-looping animation once then continue playing the state animation. public void PlayOneShot (Spine.Animation oneShot, int layerIndex) { - var state = skeletonAnimation.AnimationState; + AnimationState state = skeletonAnimation.AnimationState; state.SetAnimation(0, oneShot, false); - var transition = TryGetTransition(oneShot, TargetAnimation); + Animation transition = TryGetTransition(oneShot, TargetAnimation); if (transition != null) state.AddAnimation(0, transition, false, 0f); @@ -140,7 +140,7 @@ namespace Spine.Unity.Examples { } Spine.Animation TryGetTransition (Spine.Animation from, Spine.Animation to) { - foreach (var transition in transitions) { + foreach (AnimationTransition transition in transitions) { if (transition.from.Animation == from && transition.to.Animation == to) { return transition.transition.Animation; } @@ -153,7 +153,7 @@ namespace Spine.Unity.Examples { } Spine.Animation GetCurrentAnimation (int layerIndex) { - var currentTrackEntry = skeletonAnimation.AnimationState.GetCurrent(layerIndex); + TrackEntry currentTrackEntry = skeletonAnimation.AnimationState.GetCurrent(layerIndex); return (currentTrackEntry != null) ? currentTrackEntry.Animation : null; } diff --git a/spine-unity/Assets/Spine Examples/Scripts/MecanimAnimationMatchModifier/AnimationMatchModifierAsset.cs b/spine-unity/Assets/Spine Examples/Scripts/MecanimAnimationMatchModifier/AnimationMatchModifierAsset.cs index 8d7013247..ec72027ea 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/MecanimAnimationMatchModifier/AnimationMatchModifierAsset.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/MecanimAnimationMatchModifier/AnimationMatchModifierAsset.cs @@ -60,9 +60,9 @@ namespace Spine.Unity.Examples { // Build a reference collection of timelines to match // and a collection of dummy timelines that can be used to fill-in missing items. - var timelineDictionary = new Dictionary(); - foreach (var animation in animations) { - foreach (var timeline in animation.Timelines) { + Dictionary timelineDictionary = new Dictionary(); + foreach (Animation animation in animations) { + foreach (Timeline timeline in animation.Timelines) { if (timeline is EventTimeline) continue; foreach (string propertyId in timeline.PropertyIds) { @@ -72,20 +72,20 @@ namespace Spine.Unity.Examples { } } } - var idsToMatch = new List(timelineDictionary.Keys); + List idsToMatch = new List(timelineDictionary.Keys); // For each animation in the list, check for and add missing timelines. - var currentAnimationIDs = new HashSet(); - foreach (var animation in animations) { + HashSet currentAnimationIDs = new HashSet(); + foreach (Animation animation in animations) { currentAnimationIDs.Clear(); - foreach (var timeline in animation.Timelines) { + foreach (Timeline timeline in animation.Timelines) { if (timeline is EventTimeline) continue; foreach (string propertyId in timeline.PropertyIds) { currentAnimationIDs.Add(propertyId); } } - var animationTimelines = animation.Timelines; + ExposedList animationTimelines = animation.Timelines; foreach (string propertyId in idsToMatch) { if (!currentAnimationIDs.Contains(propertyId)) animationTimelines.Add(timelineDictionary[propertyId]); @@ -134,52 +134,52 @@ namespace Spine.Unity.Examples { } static RotateTimeline GetFillerTimeline (RotateTimeline timeline, SkeletonData skeletonData) { - var t = new RotateTimeline(1, 0, timeline.BoneIndex); + RotateTimeline t = new RotateTimeline(1, 0, timeline.BoneIndex); t.SetFrame(0, 0, 0); return t; } static TranslateTimeline GetFillerTimeline (TranslateTimeline timeline, SkeletonData skeletonData) { - var t = new TranslateTimeline(1, 0, timeline.BoneIndex); + TranslateTimeline t = new TranslateTimeline(1, 0, timeline.BoneIndex); t.SetFrame(0, 0, 0, 0); return t; } static ScaleTimeline GetFillerTimeline (ScaleTimeline timeline, SkeletonData skeletonData) { - var t = new ScaleTimeline(1, 0, timeline.BoneIndex); + ScaleTimeline t = new ScaleTimeline(1, 0, timeline.BoneIndex); t.SetFrame(0, 0, 0, 0); return t; } static ShearTimeline GetFillerTimeline (ShearTimeline timeline, SkeletonData skeletonData) { - var t = new ShearTimeline(1, 0, timeline.BoneIndex); + ShearTimeline t = new ShearTimeline(1, 0, timeline.BoneIndex); t.SetFrame(0, 0, 0, 0); return t; } static AttachmentTimeline GetFillerTimeline (AttachmentTimeline timeline, SkeletonData skeletonData) { - var t = new AttachmentTimeline(1, timeline.SlotIndex); - var slotData = skeletonData.Slots.Items[t.SlotIndex]; + AttachmentTimeline t = new AttachmentTimeline(1, timeline.SlotIndex); + SlotData slotData = skeletonData.Slots.Items[t.SlotIndex]; t.SetFrame(0, 0, slotData.AttachmentName); return t; } static RGBATimeline GetFillerTimeline (RGBATimeline timeline, SkeletonData skeletonData) { - var t = new RGBATimeline(1, 0, timeline.SlotIndex); - var slotData = skeletonData.Slots.Items[t.SlotIndex]; + RGBATimeline t = new RGBATimeline(1, 0, timeline.SlotIndex); + SlotData slotData = skeletonData.Slots.Items[t.SlotIndex]; t.SetFrame(0, 0, slotData.R, slotData.G, slotData.B, slotData.A); return t; } static RGBA2Timeline GetFillerTimeline (RGBA2Timeline timeline, SkeletonData skeletonData) { - var t = new RGBA2Timeline(1, 0, timeline.SlotIndex); - var slotData = skeletonData.Slots.Items[t.SlotIndex]; + RGBA2Timeline t = new RGBA2Timeline(1, 0, timeline.SlotIndex); + SlotData slotData = skeletonData.Slots.Items[t.SlotIndex]; t.SetFrame(0, 0, slotData.R, slotData.G, slotData.B, slotData.A, slotData.R2, slotData.G2, slotData.B2); return t; } static DeformTimeline GetFillerTimeline (DeformTimeline timeline, SkeletonData skeletonData) { - var t = new DeformTimeline(1, 0, timeline.SlotIndex, timeline.Attachment); + DeformTimeline t = new DeformTimeline(1, 0, timeline.SlotIndex, timeline.Attachment); if (t.Attachment.IsWeighted()) { t.SetFrame(0, 0, new float[t.Attachment.Vertices.Length]); } else { @@ -190,42 +190,42 @@ namespace Spine.Unity.Examples { } static DrawOrderTimeline GetFillerTimeline (DrawOrderTimeline timeline, SkeletonData skeletonData) { - var t = new DrawOrderTimeline(1); + DrawOrderTimeline t = new DrawOrderTimeline(1); t.SetFrame(0, 0, null); // null means use setup pose in DrawOrderTimeline.Apply. return t; } static IkConstraintTimeline GetFillerTimeline (IkConstraintTimeline timeline, SkeletonData skeletonData) { - var t = new IkConstraintTimeline(1, 0, timeline.IkConstraintIndex); - var ikConstraintData = skeletonData.IkConstraints.Items[timeline.IkConstraintIndex]; + IkConstraintTimeline t = new IkConstraintTimeline(1, 0, timeline.IkConstraintIndex); + IkConstraintData ikConstraintData = skeletonData.IkConstraints.Items[timeline.IkConstraintIndex]; t.SetFrame(0, 0, ikConstraintData.Mix, ikConstraintData.Softness, ikConstraintData.BendDirection, ikConstraintData.Compress, ikConstraintData.Stretch); return t; } static TransformConstraintTimeline GetFillerTimeline (TransformConstraintTimeline timeline, SkeletonData skeletonData) { - var t = new TransformConstraintTimeline(1, 0, timeline.TransformConstraintIndex); - var data = skeletonData.TransformConstraints.Items[timeline.TransformConstraintIndex]; + TransformConstraintTimeline t = new TransformConstraintTimeline(1, 0, timeline.TransformConstraintIndex); + TransformConstraintData data = skeletonData.TransformConstraints.Items[timeline.TransformConstraintIndex]; t.SetFrame(0, 0, data.MixRotate, data.MixX, data.MixY, data.MixScaleX, data.MixScaleY, data.MixShearY); return t; } static PathConstraintPositionTimeline GetFillerTimeline (PathConstraintPositionTimeline timeline, SkeletonData skeletonData) { - var t = new PathConstraintPositionTimeline(1, 0, timeline.PathConstraintIndex); - var data = skeletonData.PathConstraints.Items[timeline.PathConstraintIndex]; + PathConstraintPositionTimeline t = new PathConstraintPositionTimeline(1, 0, timeline.PathConstraintIndex); + PathConstraintData data = skeletonData.PathConstraints.Items[timeline.PathConstraintIndex]; t.SetFrame(0, 0, data.Position); return t; } static PathConstraintSpacingTimeline GetFillerTimeline (PathConstraintSpacingTimeline timeline, SkeletonData skeletonData) { - var t = new PathConstraintSpacingTimeline(1, 0, timeline.PathConstraintIndex); - var data = skeletonData.PathConstraints.Items[timeline.PathConstraintIndex]; + PathConstraintSpacingTimeline t = new PathConstraintSpacingTimeline(1, 0, timeline.PathConstraintIndex); + PathConstraintData data = skeletonData.PathConstraints.Items[timeline.PathConstraintIndex]; t.SetFrame(0, 0, data.Spacing); return t; } static PathConstraintMixTimeline GetFillerTimeline (PathConstraintMixTimeline timeline, SkeletonData skeletonData) { - var t = new PathConstraintMixTimeline(1, 0, timeline.PathConstraintIndex); - var data = skeletonData.PathConstraints.Items[timeline.PathConstraintIndex]; + PathConstraintMixTimeline t = new PathConstraintMixTimeline(1, 0, timeline.PathConstraintIndex); + PathConstraintData data = skeletonData.PathConstraints.Items[timeline.PathConstraintIndex]; t.SetFrame(0, 0, data.RotateMix, data.MixX, data.MixY); return t; } diff --git a/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipButtonExample.cs b/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipButtonExample.cs index 5e272d3df..fd264f9a4 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipButtonExample.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipButtonExample.cs @@ -51,7 +51,7 @@ namespace Spine.Unity.Examples { void Start () { MatchImage(); - var button = GetComponent