VS plugin mod for Basic Armour
Révision | d47601f2e2257160b2e9845e0576023d100a9a79 (tree) |
---|---|
l'heure | 2019-05-04 03:48:26 |
Auteur | ![]() |
Commiter | melchior |
* AmourMeshRenderer.cs: Support future head pitch
* 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
@@ -36,9 +36,9 @@ namespace ArmourMod | ||
36 | 36 | |
37 | 37 | public void OnRenderFrame(float deltaTime, EnumRenderStage stage) |
38 | 38 | { |
39 | - for (int i = 0; i < ClientApi.World.AllPlayers.Length; i++) | |
39 | + for (int i = 0; i < ClientApi.World.AllOnlinePlayers.Length; i++) | |
40 | 40 | { |
41 | - var aPlayer = ClientApi.World.AllPlayers[i]; | |
41 | + var aPlayer = ClientApi.World.AllOnlinePlayers[i]; | |
42 | 42 | |
43 | 43 | if ( aPlayer != null ) { |
44 | 44 |
@@ -51,7 +51,7 @@ namespace ArmourMod | ||
51 | 51 | { |
52 | 52 | EntityArmourPlayer armouredPlayer = aPlayer.Entity as EntityArmourPlayer; |
53 | 53 | |
54 | - if ( armouredPlayer.WornClothesItems.Count > 0 ) { | |
54 | + if ( armouredPlayer.RenderableWornArmours.Count > 0 ) { | |
55 | 55 | |
56 | 56 | RenderWornArmour( armouredPlayer, rend, stage != EnumRenderStage.Opaque ); |
57 | 57 |
@@ -77,7 +77,7 @@ namespace ArmourMod | ||
77 | 77 | if ( rpi.CameraType == EnumCameraMode.FirstPerson ) return; |
78 | 78 | } |
79 | 79 | |
80 | - foreach(var wornItemTuple in armouredPlayer.WornClothesItems) { | |
80 | + foreach(var wornItemTuple in armouredPlayer.RenderableWornArmours) { | |
81 | 81 | |
82 | 82 | if ( !Armoury.ContainsKey( wornItemTuple.Value.Code ) ) { |
83 | 83 | ClientApi.Logger.Warning( "Armoury Item Missing KEY: {0} ! ** RENDER ABORTED **", wornItemTuple.Value.Code ); |
@@ -129,15 +129,26 @@ namespace ArmourMod | ||
129 | 129 | prog.AlphaTest = 0.01f; |
130 | 130 | } |
131 | 131 | |
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 | + } | |
141 | 152 | |
142 | 153 | |
143 | 154 | if ( isShadowPass ) { |
@@ -26,9 +26,9 @@ namespace ArmourMod | ||
26 | 26 | return 1.1D; |
27 | 27 | } |
28 | 28 | |
29 | - public override bool AllowRuntimeReload() | |
29 | + public override bool AllowRuntimeReload | |
30 | 30 | { |
31 | - return false; | |
31 | + get { return false; } | |
32 | 32 | } |
33 | 33 | |
34 | 34 | public override bool ShouldLoad(EnumAppSide forSide) |
@@ -22,7 +22,7 @@ namespace ArmourMod | ||
22 | 22 | |
23 | 23 | private long client_callback; |
24 | 24 | |
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 | |
26 | 26 | |
27 | 27 | public override void Initialize(Vintagestory.API.Common.Entities.EntityProperties properties, ICoreAPI api, long chunkindex3d) |
28 | 28 | { |
@@ -30,8 +30,35 @@ namespace ArmourMod | ||
30 | 30 | |
31 | 31 | CoreAPI = api; |
32 | 32 | 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 | + } | |
33 | 39 | } |
34 | 40 | |
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 | + | |
35 | 62 | public override void OnEntitySpawn() |
36 | 63 | { |
37 | 64 | base.OnEntitySpawn(); |
@@ -51,20 +78,7 @@ namespace ArmourMod | ||
51 | 78 | |
52 | 79 | //Walk Inventory FIRST TIME ONLY |
53 | 80 | 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 | + } | |
68 | 82 | } |
69 | 83 | |
70 | 84 | public override void Die(EnumDespawnReason reason = EnumDespawnReason.Death, DamageSource damageSourceForDeath = null) |
@@ -96,7 +110,7 @@ namespace ArmourMod | ||
96 | 110 | //clear client side entry too! |
97 | 111 | if ( loseArmourOnDeath ) { |
98 | 112 | |
99 | - this.WornClothesItems.Clear( ); | |
113 | + this.RenderableWornArmours.Clear( ); | |
100 | 114 | } |
101 | 115 | } |
102 | 116 | } |
@@ -147,7 +161,7 @@ namespace ArmourMod | ||
147 | 161 | if ( !watchedSlot.Empty ) { |
148 | 162 | |
149 | 163 | if ( watchedSlot.StorageType == EnumItemStorageFlags.Outfit && watchedSlot.Itemstack.Class == EnumItemClass.Item ) { |
150 | - if (CheckIfClothesIsArmour(watchedSlot)) | |
164 | + if (CheckIfClothesIsArmour(watchedSlot) && CheckForCustomMesh(watchedSlot)) | |
151 | 165 | { |
152 | 166 | WearArmorModel( slotId, watchedSlot.Itemstack.Item ); |
153 | 167 | } |
@@ -241,11 +255,11 @@ namespace ArmourMod | ||
241 | 255 | |
242 | 256 | private void WearArmorModel(int slotId, Item wornArmour) |
243 | 257 | { |
244 | - if ( !WornClothesItems.ContainsKey( (EnumCharacterDressType)slotId ) ) { | |
258 | + if ( !RenderableWornArmours.ContainsKey( (EnumCharacterDressType)slotId ) ) { | |
245 | 259 | #if DEBUG |
246 | 260 | Logger.VerboseDebug( "Wearing: {0}", wornArmour.Code.ToString( ) ); |
247 | 261 | #endif |
248 | - WornClothesItems.Add( (EnumCharacterDressType)slotId, wornArmour ); | |
262 | + RenderableWornArmours.Add( (EnumCharacterDressType)slotId, wornArmour ); | |
249 | 263 | } else { |
250 | 264 | #if DEBUG |
251 | 265 | Logger.VerboseDebug( "Duplicate of SlotId {0} worn Armour: {1}",slotId ,wornArmour.Code.ToString( ) ); |
@@ -255,12 +269,12 @@ namespace ArmourMod | ||
255 | 269 | |
256 | 270 | private void UnwearArmorModel(int slotId) |
257 | 271 | { |
258 | - if ( WornClothesItems.ContainsKey( (EnumCharacterDressType)slotId ) ) { | |
259 | - var armourItem = WornClothesItems[(EnumCharacterDressType)slotId]; | |
272 | + if ( RenderableWornArmours.ContainsKey( (EnumCharacterDressType)slotId ) ) { | |
273 | + var armourItem = RenderableWornArmours[(EnumCharacterDressType)slotId]; | |
260 | 274 | #if DEBUG |
261 | 275 | Logger.VerboseDebug( "UN-Wearing: {0}", armourItem.Code.ToString( ) ); |
262 | 276 | #endif |
263 | - WornClothesItems.Remove( (EnumCharacterDressType)slotId ); | |
277 | + RenderableWornArmours.Remove( (EnumCharacterDressType)slotId ); | |
264 | 278 | } else { |
265 | 279 | #if DEBUG |
266 | 280 | Logger.VerboseDebug( "Non-armour removed, slotID{0}", slotId ); |
@@ -283,7 +297,7 @@ namespace ArmourMod | ||
283 | 297 | #if DEBUG |
284 | 298 | Logger.VerboseDebug( "Already wearing armour:{0}", itemSlot.Itemstack.Item.Code.ToString( ) ); |
285 | 299 | #endif |
286 | - WornClothesItems.Add( (EnumCharacterDressType)slotId, itemSlot.Itemstack.Item ); | |
300 | + RenderableWornArmours.Add( (EnumCharacterDressType)slotId, itemSlot.Itemstack.Item ); | |
287 | 301 | } |
288 | 302 | } |
289 | 303 | } |
@@ -365,6 +379,24 @@ namespace ArmourMod | ||
365 | 379 | return false; |
366 | 380 | } |
367 | 381 | |
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 | + | |
368 | 400 | public static DamageFilter ConstructFilter(ItemSlot armourInSlot) |
369 | 401 | { |
370 | 402 | var blunt = armourInSlot.Itemstack.ItemAttributes["BluntProtection"].AsFloat( ); |
@@ -65,7 +65,7 @@ | ||
65 | 65 | scale: 3.75 |
66 | 66 | }, |
67 | 67 | thirdPersonTransform: { |
68 | - translation: { x: -0.020, y: 0.09, z: -0.05 }, | |
68 | + translation: { x: -0.020, y: 0.1, z: 0.00 }, | |
69 | 69 | rotation: { x: 0, y: 0, z: 0 }, |
70 | 70 | scale: 1.1 |
71 | 71 | } |
@@ -3,9 +3,9 @@ | ||
3 | 3 | "name": "Basic Armour Mod", |
4 | 4 | "description" : "Leather, Plate, Scale & More", |
5 | 5 | "authors": ["Melchior", "Bunnyviking"], |
6 | - "version": "0.1.1", | |
6 | + "version": "0.1.2", | |
7 | 7 | "dependencies": { |
8 | - "game": "", | |
8 | + "game": "1.9.0-rc.4", | |
9 | 9 | "survival": "" |
10 | 10 | }, |
11 | 11 | "website": "http://nowebsite.nope" |