• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

VS plugin mod for Basic Armour


Commit MetaInfo

Révisiond47601f2e2257160b2e9845e0576023d100a9a79 (tree)
l'heure2019-05-04 03:48:26
Auteurmelchior <melchior@user...>
Commitermelchior

Message de Log

* AmourMeshRenderer.cs: Support future head pitch

rotations...eventually.

* ArmourModHookin.cs: V1.9 RC updates

* EntityArmourPlayer.cs: V1.9 related event / timing changes

* clothes-head-potmetal.json: tweaked coordinates

* modinfo.json: version minimum and, mod info update

Change Summary

Modification

--- a/ArmourMod/Armour/AmourMeshRenderer.cs
+++ b/ArmourMod/Armour/AmourMeshRenderer.cs
@@ -36,9 +36,9 @@ namespace ArmourMod
3636
3737 public void OnRenderFrame(float deltaTime, EnumRenderStage stage)
3838 {
39- for (int i = 0; i < ClientApi.World.AllPlayers.Length; i++)
39+ for (int i = 0; i < ClientApi.World.AllOnlinePlayers.Length; i++)
4040 {
41- var aPlayer = ClientApi.World.AllPlayers[i];
41+ var aPlayer = ClientApi.World.AllOnlinePlayers[i];
4242
4343 if ( aPlayer != null ) {
4444
@@ -51,7 +51,7 @@ namespace ArmourMod
5151 {
5252 EntityArmourPlayer armouredPlayer = aPlayer.Entity as EntityArmourPlayer;
5353
54- if ( armouredPlayer.WornClothesItems.Count > 0 ) {
54+ if ( armouredPlayer.RenderableWornArmours.Count > 0 ) {
5555
5656 RenderWornArmour( armouredPlayer, rend, stage != EnumRenderStage.Opaque );
5757
@@ -77,7 +77,7 @@ namespace ArmourMod
7777 if ( rpi.CameraType == EnumCameraMode.FirstPerson ) return;
7878 }
7979
80- foreach(var wornItemTuple in armouredPlayer.WornClothesItems) {
80+ foreach(var wornItemTuple in armouredPlayer.RenderableWornArmours) {
8181
8282 if ( !Armoury.ContainsKey( wornItemTuple.Value.Code ) ) {
8383 ClientApi.Logger.Warning( "Armoury Item Missing KEY: {0} ! ** RENDER ABORTED **", wornItemTuple.Value.Code );
@@ -129,15 +129,26 @@ namespace ArmourMod
129129 prog.AlphaTest = 0.01f;
130130 }
131131
132- armourModelMatrix
133- .Scale( armourData.Armour_Transform.ScaleXYZ.X, armourData.Armour_Transform.ScaleXYZ.Y, armourData.Armour_Transform.ScaleXYZ.Z )
134- .Translate( attachPt.PosX / 16d + armourData.Armour_Transform.Translation.X, attachPt.PosY / 16d + armourData.Armour_Transform.Translation.Y, attachPt.PosZ / 16d + armourData.Armour_Transform.Translation.Z )
135- .RotateX( (float)(attachPt.RotationX + armourData.Armour_Transform.Rotation.X) * GameMath.DEG2RAD )
136- .RotateY( (float)(attachPt.RotationY + armourData.Armour_Transform.Rotation.Y) * GameMath.DEG2RAD )
137- .RotateZ( (float)(attachPt.RotationZ + armourData.Armour_Transform.Rotation.Z) * GameMath.DEG2RAD )
138- .Translate(-(armourData.Armour_Transform.Origin.X), -(armourData.Armour_Transform.Origin.Y), -(armourData.Armour_Transform.Origin.Z));
139-
140-
132+ if ( wornItemTuple.Key == EnumCharacterDressType.Head ) {
133+ //Apply Head pitch for helmets
134+ //ClientApi.World.Player.Entity.HeadPitch
135+ armourModelMatrix
136+ .Scale( armourData.Armour_Transform.ScaleXYZ.X, armourData.Armour_Transform.ScaleXYZ.Y, armourData.Armour_Transform.ScaleXYZ.Z )
137+ .Translate( attachPt.PosX / 16d + armourData.Armour_Transform.Translation.X, attachPt.PosY / 16d + armourData.Armour_Transform.Translation.Y, attachPt.PosZ / 16d + armourData.Armour_Transform.Translation.Z )
138+ .RotateX( (float)(attachPt.RotationX + armourData.Armour_Transform.Rotation.X) * GameMath.DEG2RAD )
139+ .RotateY( (float)(attachPt.RotationY + armourData.Armour_Transform.Rotation.Y) * GameMath.DEG2RAD )
140+ .RotateZ( (float)(attachPt.RotationZ + armourData.Armour_Transform.Rotation.Z) * GameMath.DEG2RAD )
141+ .Translate( -(armourData.Armour_Transform.Origin.X), -(armourData.Armour_Transform.Origin.Y), -(armourData.Armour_Transform.Origin.Z) );
142+ } else
143+ {
144+ armourModelMatrix
145+ .Scale( armourData.Armour_Transform.ScaleXYZ.X, armourData.Armour_Transform.ScaleXYZ.Y, armourData.Armour_Transform.ScaleXYZ.Z )
146+ .Translate( attachPt.PosX / 16d + armourData.Armour_Transform.Translation.X, attachPt.PosY / 16d + armourData.Armour_Transform.Translation.Y, attachPt.PosZ / 16d + armourData.Armour_Transform.Translation.Z )
147+ .RotateX( (float)(attachPt.RotationX + armourData.Armour_Transform.Rotation.X) * GameMath.DEG2RAD )
148+ .RotateY( (float)(attachPt.RotationY + armourData.Armour_Transform.Rotation.Y) * GameMath.DEG2RAD )
149+ .RotateZ( (float)(attachPt.RotationZ + armourData.Armour_Transform.Rotation.Z) * GameMath.DEG2RAD )
150+ .Translate( -(armourData.Armour_Transform.Origin.X), -(armourData.Armour_Transform.Origin.Y), -(armourData.Armour_Transform.Origin.Z) );
151+ }
141152
142153
143154 if ( isShadowPass ) {
--- a/ArmourMod/Armour/ArmourModHookin.cs
+++ b/ArmourMod/Armour/ArmourModHookin.cs
@@ -26,9 +26,9 @@ namespace ArmourMod
2626 return 1.1D;
2727 }
2828
29- public override bool AllowRuntimeReload()
29+ public override bool AllowRuntimeReload
3030 {
31- return false;
31+ get { return false; }
3232 }
3333
3434 public override bool ShouldLoad(EnumAppSide forSide)
--- a/ArmourMod/Armour/EntityArmourPlayer.cs
+++ b/ArmourMod/Armour/EntityArmourPlayer.cs
@@ -22,7 +22,7 @@ namespace ArmourMod
2222
2323 private long client_callback;
2424
25- public Dictionary<EnumCharacterDressType,Item> WornClothesItems { get; private set;}//Needs to be client side
25+ public Dictionary<EnumCharacterDressType,Item> RenderableWornArmours { get; private set;}//Needs to be client side
2626
2727 public override void Initialize(Vintagestory.API.Common.Entities.EntityProperties properties, ICoreAPI api, long chunkindex3d)
2828 {
@@ -30,8 +30,35 @@ namespace ArmourMod
3030
3131 CoreAPI = api;
3232 Logger = api.World.Logger;
33+
34+ if (CoreAPI.Side.IsClient())
35+ {
36+ this.RenderableWornArmours = new Dictionary<EnumCharacterDressType, Item>(); // BEFORE RENDERER GETS THERE!
37+ Logger.VerboseDebug("Renderable Worn Armours Dict assigned");
38+ }
3339 }
3440
41+ public override void OnEntityLoaded()
42+ {
43+ base.OnEntityLoaded();
44+ Logger.VerboseDebug( "OnEntityLoaded - EntityArmourPlayer" );
45+
46+ Logger.VerboseDebug( "Side:{0}, gearInv == null?{1}", CoreAPI.Side.ToString( ), base.GearInventory == null );
47+
48+ if ( CoreAPI.Side == EnumAppSide.Client ) {
49+
50+ //Attach to Inventory events
51+ #if DEBUG
52+ Logger.VerboseDebug( "Side:{0}, gearInv == null?{1}", CoreAPI.Side.ToString( ), base.GearInventory == null );
53+ #endif
54+
55+ //base.GearInventory.SlotModified += ClientWatchSlotModified;
56+
57+ client_callback = CoreAPI.Event.RegisterCallback( ClientDelayHook, 300 );
58+ }
59+ }
60+
61+
3562 public override void OnEntitySpawn()
3663 {
3764 base.OnEntitySpawn();
@@ -51,20 +78,7 @@ namespace ArmourMod
5178
5279 //Walk Inventory FIRST TIME ONLY
5380 PopulateDamageFilters();
54- }
55-
56- if ( CoreAPI.Side == EnumAppSide.Client ) {
57- this.WornClothesItems = new Dictionary<EnumCharacterDressType, Item>();
58-
59- //Attach to Inventory events
60- #if DEBUG
61- Logger.VerboseDebug( "Side:{0}, gearInv == null?{1}", CoreAPI.Side.ToString( ), base.GearInventory == null );
62- #endif
63-
64- //base.GearInventory.SlotModified += ClientWatchSlotModified;
65-
66- client_callback = CoreAPI.Event.RegisterCallback( ClientDelayHook, 300 );
67- }
81+ }
6882 }
6983
7084 public override void Die(EnumDespawnReason reason = EnumDespawnReason.Death, DamageSource damageSourceForDeath = null)
@@ -96,7 +110,7 @@ namespace ArmourMod
96110 //clear client side entry too!
97111 if ( loseArmourOnDeath ) {
98112
99- this.WornClothesItems.Clear( );
113+ this.RenderableWornArmours.Clear( );
100114 }
101115 }
102116 }
@@ -147,7 +161,7 @@ namespace ArmourMod
147161 if ( !watchedSlot.Empty ) {
148162
149163 if ( watchedSlot.StorageType == EnumItemStorageFlags.Outfit && watchedSlot.Itemstack.Class == EnumItemClass.Item ) {
150- if (CheckIfClothesIsArmour(watchedSlot))
164+ if (CheckIfClothesIsArmour(watchedSlot) && CheckForCustomMesh(watchedSlot))
151165 {
152166 WearArmorModel( slotId, watchedSlot.Itemstack.Item );
153167 }
@@ -241,11 +255,11 @@ namespace ArmourMod
241255
242256 private void WearArmorModel(int slotId, Item wornArmour)
243257 {
244- if ( !WornClothesItems.ContainsKey( (EnumCharacterDressType)slotId ) ) {
258+ if ( !RenderableWornArmours.ContainsKey( (EnumCharacterDressType)slotId ) ) {
245259 #if DEBUG
246260 Logger.VerboseDebug( "Wearing: {0}", wornArmour.Code.ToString( ) );
247261 #endif
248- WornClothesItems.Add( (EnumCharacterDressType)slotId, wornArmour );
262+ RenderableWornArmours.Add( (EnumCharacterDressType)slotId, wornArmour );
249263 } else {
250264 #if DEBUG
251265 Logger.VerboseDebug( "Duplicate of SlotId {0} worn Armour: {1}",slotId ,wornArmour.Code.ToString( ) );
@@ -255,12 +269,12 @@ namespace ArmourMod
255269
256270 private void UnwearArmorModel(int slotId)
257271 {
258- if ( WornClothesItems.ContainsKey( (EnumCharacterDressType)slotId ) ) {
259- var armourItem = WornClothesItems[(EnumCharacterDressType)slotId];
272+ if ( RenderableWornArmours.ContainsKey( (EnumCharacterDressType)slotId ) ) {
273+ var armourItem = RenderableWornArmours[(EnumCharacterDressType)slotId];
260274 #if DEBUG
261275 Logger.VerboseDebug( "UN-Wearing: {0}", armourItem.Code.ToString( ) );
262276 #endif
263- WornClothesItems.Remove( (EnumCharacterDressType)slotId );
277+ RenderableWornArmours.Remove( (EnumCharacterDressType)slotId );
264278 } else {
265279 #if DEBUG
266280 Logger.VerboseDebug( "Non-armour removed, slotID{0}", slotId );
@@ -283,7 +297,7 @@ namespace ArmourMod
283297 #if DEBUG
284298 Logger.VerboseDebug( "Already wearing armour:{0}", itemSlot.Itemstack.Item.Code.ToString( ) );
285299 #endif
286- WornClothesItems.Add( (EnumCharacterDressType)slotId, itemSlot.Itemstack.Item );
300+ RenderableWornArmours.Add( (EnumCharacterDressType)slotId, itemSlot.Itemstack.Item );
287301 }
288302 }
289303 }
@@ -365,6 +379,24 @@ namespace ArmourMod
365379 return false;
366380 }
367381
382+ public static bool CheckForCustomMesh(ItemSlot possibleArmour)
383+ {
384+ if (possibleArmour.Itemstack != null && possibleArmour.Itemstack.Item.Code.BeginsWith( "armourmod", "clothes" ) ) {
385+
386+ if (possibleArmour.Itemstack.ItemAttributes.Exists)
387+ {
388+ //shape: { base: "entity/humanoid/seraph" },
389+
390+ if (possibleArmour.Itemstack.Item.Shape != null)
391+ {
392+ return possibleArmour.Itemstack.Item.Shape.Base.BeginsWith( "game", "seraph" ) == false;
393+ }
394+ }
395+ }
396+
397+ return false;
398+ }
399+
368400 public static DamageFilter ConstructFilter(ItemSlot armourInSlot)
369401 {
370402 var blunt = armourInSlot.Itemstack.ItemAttributes["BluntProtection"].AsFloat( );
--- a/ArmourMod/assets/armourmod/itemtypes/wearable/clothes-head-potmetal.json
+++ b/ArmourMod/assets/armourmod/itemtypes/wearable/clothes-head-potmetal.json
@@ -65,7 +65,7 @@
6565 scale: 3.75
6666 },
6767 thirdPersonTransform: {
68- translation: { x: -0.020, y: 0.09, z: -0.05 },
68+ translation: { x: -0.020, y: 0.1, z: 0.00 },
6969 rotation: { x: 0, y: 0, z: 0 },
7070 scale: 1.1
7171 }
--- a/ArmourMod/modinfo.json
+++ b/ArmourMod/modinfo.json
@@ -3,9 +3,9 @@
33 "name": "Basic Armour Mod",
44 "description" : "Leather, Plate, Scale & More",
55 "authors": ["Melchior", "Bunnyviking"],
6- "version": "0.1.1",
6+ "version": "0.1.2",
77 "dependencies": {
8- "game": "",
8+ "game": "1.9.0-rc.4",
99 "survival": ""
1010 },
1111 "website": "http://nowebsite.nope"