Fix swapped names of SetItem and Plastique
Add plastique to debug menu spawn Make plastique damage player Make plastique deal double damage to demon wall Fix prompt for setting vs using plastique
This commit is contained in:
@@ -92,9 +92,9 @@ public partial class Inventory : Node, IInventory
|
||||
var throwables = listToSort.Where(x => x is ThrowableItem).OrderBy(x => x as ThrowableItem, new ThrowableComparer());
|
||||
var effectItems = listToSort.Where(x => x is EffectItem).OrderBy(x => x as EffectItem, new EffectComparer());
|
||||
var jewelItems = listToSort.Where(x => x is Jewel).OrderBy(x => x as Jewel, new JewelComparer());
|
||||
var setItems = listToSort.Where(x => x is Plastique).OrderBy(x => x as Plastique, new SetItemComparer());
|
||||
var setItems = listToSort.Where(x => x is Plastique).OrderBy(x => x as SetItem, new SetItemComparer());
|
||||
var boxItems = listToSort.Where(x => x is BoxItem).OrderBy(x => x as BoxItem, new BoxItemComparer());
|
||||
Items = [.. equippedItems, .. weapons, .. armor, .. accessories, .. ammo, .. consumables, .. throwables, .. effectItems, .. jewelItems, ..boxItems, .. setItems];
|
||||
Items = [.. equippedItems, .. weapons, .. armor, .. accessories, .. ammo, .. consumables, .. throwables, .. effectItems, .. jewelItems, .. boxItems, .. setItems];
|
||||
|
||||
var stackableItems = Items.OfType<IStackable>();
|
||||
var itemsToStack = stackableItems.GroupBy(x => ((IBaseInventoryItem)x).ItemName).Where(x => x.Count() > 1);
|
||||
@@ -156,9 +156,9 @@ public partial class Inventory : Node, IInventory
|
||||
}
|
||||
}
|
||||
|
||||
public class SetItemComparer : IComparer<Plastique>
|
||||
public class SetItemComparer : IComparer<SetItem>
|
||||
{
|
||||
public int Compare(Plastique x, Plastique y)
|
||||
public int Compare(SetItem x, SetItem y)
|
||||
{
|
||||
return x.ItemName.CompareTo(y.ItemName);
|
||||
}
|
||||
|
||||
@@ -150,6 +150,9 @@ public class ItemDatabase
|
||||
database.Add(jewelItemScene);
|
||||
}
|
||||
|
||||
var plastiqueScene = ResourceLoader.Load<PackedScene>("res://src/items/misc/SetItem.tscn").Instantiate<SetItem>();
|
||||
database.Add(plastiqueScene);
|
||||
|
||||
Items = [.. database];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,70 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
using Godot;
|
||||
using System;
|
||||
using Zennysoft.Game.Ma;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
using Zennysoft.Ma.Adapter.Entity;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Plastique : Node3D, IBaseInventoryItem
|
||||
public partial class Plastique : RigidBody3D
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node] private Sprite3D _sprite { get; set; }
|
||||
[Node] public AnimationTree AnimationTree { get; set; }
|
||||
|
||||
public string ItemName => Stats.Name;
|
||||
[Node] public Area3D ExplosionArea { get; set; }
|
||||
|
||||
public string StatDescription => Stats.StatDescription;
|
||||
[Dependency] public IPlayer Player => this.DependOn<IPlayer>();
|
||||
|
||||
public string FlavorText => Stats.FlavorText;
|
||||
[Export] public int ExplosionDamage { get; set; } = 10;
|
||||
|
||||
public float SpawnRate => Stats.SpawnRate;
|
||||
protected AnimationNodeStateMachinePlayback _stateMachine;
|
||||
|
||||
public int ThrowDamage => Stats.ThrowDamage;
|
||||
protected readonly string _parametersPlayback = "parameters/playback";
|
||||
|
||||
public float ThrowSpeed => Stats.ThrowSpeed;
|
||||
|
||||
public ItemTag ItemTag => Stats.ItemTag;
|
||||
|
||||
public void OnResolved()
|
||||
public void OnReady()
|
||||
{
|
||||
_sprite.Texture = Stats.Texture;
|
||||
_stateMachine = (AnimationNodeStateMachinePlayback)AnimationTree.Get(_parametersPlayback);
|
||||
ExplosionArea.AreaEntered += ExplosionArea_AreaEntered;
|
||||
AnimationTree.AnimationFinished += AnimationTree_AnimationFinished;
|
||||
}
|
||||
|
||||
public Texture2D GetTexture() => Stats.Texture;
|
||||
private void AnimationTree_AnimationFinished(StringName animName)
|
||||
{
|
||||
if (animName == "explode")
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
[Export]
|
||||
[Save("inventory_stats")]
|
||||
public EffectItemStats Stats { get; set; } = new EffectItemStats();
|
||||
private void ExplosionArea_AreaEntered(Area3D area)
|
||||
{
|
||||
if (area.GetParent() is ExplodableWall wall)
|
||||
wall.Demolish();
|
||||
if (area.GetOwner() is DemonWall demonWall)
|
||||
demonWall.HealthComponent.Damage(ExplosionDamage * 2, ElementType.Igneous);
|
||||
else if (area.GetOwner() is IEnemy enemy)
|
||||
enemy.HealthComponent.Damage(ExplosionDamage, ElementType.Igneous);
|
||||
else if (area.GetOwner() is IPlayer player)
|
||||
player.TakeDamage(new AttackData(ExplosionDamage, ElementType.Igneous));
|
||||
}
|
||||
|
||||
public async void Set()
|
||||
{
|
||||
AddCollisionExceptionWith((Node)Player);
|
||||
GlobalPosition = Player.GlobalPosition + Vector3.Up;
|
||||
ApplyCentralImpulse(-Player.GlobalBasis.Z.Normalized() * 5.0f);
|
||||
await ToSignal(GetTree().CreateTimer(1), "timeout");
|
||||
Explode();
|
||||
}
|
||||
|
||||
public void Explode()
|
||||
{
|
||||
_stateMachine.Travel("timer");
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
ExplosionArea.AreaEntered -= ExplosionArea_AreaEntered;
|
||||
AnimationTree.AnimationFinished -= AnimationTree_AnimationFinished;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,63 +1,39 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
using Godot;
|
||||
using System;
|
||||
using Zennysoft.Game.Ma;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
using Zennysoft.Ma.Adapter.Entity;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class SetItem : RigidBody3D
|
||||
public partial class SetItem : Node3D, IBaseInventoryItem
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node] public AnimationTree AnimationTree { get; set; }
|
||||
[Node] private Sprite3D _sprite { get; set; }
|
||||
|
||||
[Node] public Area3D ExplosionArea { get; set; }
|
||||
public string ItemName => Stats.Name;
|
||||
|
||||
[Dependency] public IPlayer Player => this.DependOn<IPlayer>();
|
||||
public string StatDescription => Stats.StatDescription;
|
||||
|
||||
protected AnimationNodeStateMachinePlayback _stateMachine;
|
||||
public string FlavorText => Stats.FlavorText;
|
||||
|
||||
protected readonly string _parametersPlayback = "parameters/playback";
|
||||
public float SpawnRate => Stats.SpawnRate;
|
||||
|
||||
public void OnReady()
|
||||
public int ThrowDamage => Stats.ThrowDamage;
|
||||
|
||||
public float ThrowSpeed => Stats.ThrowSpeed;
|
||||
|
||||
public ItemTag ItemTag => Stats.ItemTag;
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
_stateMachine = (AnimationNodeStateMachinePlayback)AnimationTree.Get(_parametersPlayback);
|
||||
ExplosionArea.AreaEntered += ExplosionArea_AreaEntered;
|
||||
AnimationTree.AnimationFinished += AnimationTree_AnimationFinished;
|
||||
_sprite.Texture = Stats.Texture;
|
||||
}
|
||||
|
||||
private void AnimationTree_AnimationFinished(StringName animName)
|
||||
{
|
||||
if (animName == "explode")
|
||||
QueueFree();
|
||||
}
|
||||
public Texture2D GetTexture() => Stats.Texture;
|
||||
|
||||
private void ExplosionArea_AreaEntered(Area3D area)
|
||||
{
|
||||
if (area.GetParent() is ExplodableWall wall)
|
||||
wall.Demolish();
|
||||
if (area.GetOwner() is IEnemy enemy)
|
||||
enemy.HealthComponent.Damage(10, ElementType.Igneous);
|
||||
}
|
||||
|
||||
public async void Set()
|
||||
{
|
||||
AddCollisionExceptionWith((Node)Player);
|
||||
GlobalPosition = Player.GlobalPosition + Vector3.Up;
|
||||
ApplyCentralImpulse(-Player.GlobalBasis.Z.Normalized() * 5.0f);
|
||||
await ToSignal(GetTree().CreateTimer(1), "timeout");
|
||||
Explode();
|
||||
}
|
||||
|
||||
public void Explode()
|
||||
{
|
||||
_stateMachine.Travel("timer");
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
ExplosionArea.AreaEntered -= ExplosionArea_AreaEntered;
|
||||
AnimationTree.AnimationFinished -= AnimationTree_AnimationFinished;
|
||||
}
|
||||
[Export]
|
||||
[Save("inventory_stats")]
|
||||
public EffectItemStats Stats { get; set; } = new EffectItemStats();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user