RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
CombatProjectileParser.java
1package com.osroyale.util.parser.impl;
2
3import com.google.gson.JsonObject;
4import com.osroyale.game.Animation;
5import com.osroyale.game.Graphic;
6import com.osroyale.game.Projectile;
7import com.osroyale.game.world.entity.combat.CombatImpact;
8import com.osroyale.game.world.entity.combat.magic.MagicImpact;
9import com.osroyale.game.world.entity.combat.projectile.CombatProjectile;
10import com.osroyale.game.world.entity.combat.ranged.RangedEffects;
11import com.osroyale.util.parser.GsonParser;
12
33
34public class CombatProjectileParser extends GsonParser {
35
36 public CombatProjectileParser() {
37 super("def/combat/projectile_definitions", false);
38 }
39
40 @Override
41 public void parse(JsonObject reader){
42 String name = reader.get("name").getAsString();
43
44 int hitDelay = -1;
45 if (reader.has("hit-delay")) {
46 hitDelay = reader.get("hit-delay").getAsInt();
47 }
48
49 int hitsplatDelay = -1;
50 if (reader.has("hitsplat-delay")) {
51 hitsplatDelay = reader.get("hitsplat-delay").getAsInt();
52 }
53
54 int maxHit = -1;
55 if (reader.has("max-hit")) {
56 maxHit = reader.get("max-hit").getAsInt();
57 }
58
59 CombatImpact effect = null;
60 if (reader.has("magic-effect")) {
61 String effectName = reader.get("magic-effect").getAsString();
62 effect = MagicImpact.valueOf(effectName).getEffect();
63 } else if (reader.has("ranged-effect")) {
64 String effectName = reader.get("ranged-effect").getAsString();
65 effect = RangedEffects.valueOf(effectName).getEffect();
66 }
67
68 Animation animation = null;
69 if (reader.has("animation")) {
70 animation = builder.fromJson(reader.get("animation"), Animation.class);
71 }
72
73 Graphic start = null;
74 if (reader.has("start")) {
75 start = builder.fromJson(reader.get("start"), Graphic.class);
76 }
77
78 Graphic end = null;
79 if (reader.has("end")) {
80 end = builder.fromJson(reader.get("end"), Graphic.class);
81 }
82
83 Projectile projectile = null;
84 if (reader.has("projectile")) {
85 projectile = builder.fromJson(reader.get("projectile"), Projectile.class);
86 }
87
88 CombatProjectile.definitions.put(name, new CombatProjectile(name, maxHit, effect, animation, start, end, projectile, hitDelay, hitsplatDelay));
89 }
90
91}