Skip to content

Commit

Permalink
Added a custom model and a new sprite for the black powder
Browse files Browse the repository at this point in the history
  • Loading branch information
VELD-Dev committed Apr 22, 2023
1 parent ee072e8 commit 5380b49
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 78 deletions.
Binary file modified AlterraWeaponry/alterraweaponry.assets
Binary file not shown.
2 changes: 1 addition & 1 deletion AlterraWeaponry/behaviours/TorpedoExplosionBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class TorpedoExplosionBehaviour : MonoBehaviour
public void Start()
{
DamageSystem.RadiusDamage(250f, base.gameObject.transform.position, 5f, DamageType.Explosive, base.gameObject);
Utils.PlayOneShotPS(VFXSunbeam.main.explosionPrefab, base.gameObject.transform.position, base.gameObject.transform.rotation, null);
Utils.PlayOneShotPS(new VFXMeteor().impactPrefab, base.gameObject.transform.position, base.gameObject.transform.rotation, null);
UnityEngine.Object.Destroy(base.gameObject);
}

Expand Down
84 changes: 7 additions & 77 deletions AlterraWeaponry/items/BlackPowder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace VELD.AlterraWeaponry.items;

internal class BlackPowder : Craftable
{
public static GameObject prefab = Main.assets.LoadAsset<GameObject>("GameObject.BlackPowder");
public static GameObject AssetPrefab = Main.assets.LoadAsset<GameObject>("GameObject.BlackPowder");
public static GameObject prefab;
public static TechType techType { get; private set; } = 0;

public BlackPowder() : base("BlackPowder", "BlackPowder", "Tooltip_BlackPowder")
Expand Down Expand Up @@ -55,90 +56,19 @@ public override GameObject GetGameObject()
PrefabIdentifier prefabIdentifier = prefab.AddComponent<PrefabIdentifier>();
prefabIdentifier.ClassId = base.ClassID;
prefabIdentifier.name = base.ClassID;
Rigidbody rigidbody = prefab.AddComponent<Rigidbody>();
rigidbody.useGravity = false;
rigidbody.mass = 1f;
prefab.AddComponent<WorldForces>();
LargeWorldEntity largeWorldEntity = prefab.AddComponent<LargeWorldEntity>();
prefab.AddComponent<LargeWorldEntity>();
TechTag techTag = prefab.AddComponent<TechTag>();
techTag.type = base.TechType;
Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>();
Shader shader = Shader.Find("MarmosetUBER");
for(int i = 0; i < componentsInChildren.Length; i++)
{
for(int ind = 0; ind < componentsInChildren[i].materials.Length; ind++)
{
Material material = componentsInChildren[i].materials[ind];
Texture texture = material.GetTexture("_SpecGlossMap");
Texture texture2 = material.GetTexture("_EmissionMap");
material.shader = shader;
material.DisableKeyword("_SPECGLOSSMAP");
material.DisableKeyword("_NORMALMAP");
bool flag2 = texture != null;
if (flag2)
{
material.SetTexture("_SpecTex", texture);
material.SetFloat("_SpecInt", 1f);
material.SetFloat("_Shininess", 4f);
material.EnableKeyword("MARMO_SPECMAP");
material.SetColor("_SpecColor", new(1f, 1f, 1f, 1f));
material.SetFloat("_Fresnel", 0.24f);
material.SetVector("_SpecTex_ST", new(1f, 1f, 0f, 0f));
}
bool flag3 = material.IsKeywordEnabled("_EMMISSION");
if(flag3)
{
material.EnableKeyword("MARMO_EMISSION");
material.SetFloat("_EnableGlow", 1f);
material.SetTexture("_Illum", texture2);
material.SetFloat("_GlowStrenght", 1f);
material.SetFloat("_GlowStrengthNight", 1f);
}
bool flag4 = material.GetTexture("_BumpMap");
if(flag4)
{
material.EnableKeyword("MARMO_NORMALMAP");
}
bool flag5 = material.name.ToLower().Contains("cutout");
if(flag5)
{
material.EnableKeyword("MARMO_ALPHA_CLIP");
}
bool flag6 = material.name.ToLower().Contains("transparent");
if(flag6)
{
material.EnableKeyword("_ZWRITE_ON");
material.EnableKeyword("WBOIT");
material.SetInt("_ZWrite", 0);
material.SetInt("_Cutoff", 0);
material.SetFloat("_SrcBlend", 1f);
material.SetFloat("_DstBlend", 1f);
material.SetFloat("_SrcBlend2", 0f);
material.SetFloat("_DstBlend2", 10f);
material.SetFloat("_AddSrcBlend", 1f);
material.SetFloat("_AddDstBlend", 1f);
material.SetFloat("_AddSrcBlend2", 0f);
material.SetFloat("_AddDstBlend2", 10f);
material.globalIlluminationFlags = (MaterialGlobalIlluminationFlags.RealtimeEmissive | MaterialGlobalIlluminationFlags.EmissiveIsBlack);
material.renderQueue = 3101;
material.enableInstancing = true;
}
}
}
prefab.SetActive(true);
}
prefab.SetActive(true);
GameObject go = UnityEngine.Object.Instantiate<GameObject>(prefab);
//go.transform.GetChild(0).localPosition = new(0, 0, 0);
//go.transform.GetChild(0).localEulerAngles = new(-90f, 0, 0);
return go;
}
public override IEnumerator GetGameObjectAsync(IOut<GameObject> gameObject)
{
CoroutineTask<GameObject> task = CraftData.GetPrefabForTechTypeAsync(TechType.Sulphur);
yield return task;
GameObject go = GameObject.Instantiate(task.GetResult());

// Don't forget to change to custom prefab or try to get the alternative prefab as fast as possible.
gameObject.Set(go);
gameObject.Set(this.GetGameObject());
yield return null;
yield break;
}
}

0 comments on commit 5380b49

Please sign in to comment.