HealthReworkFuckMojMozg

This commit is contained in:
ThomasCharester committed 2026-03-22 10:32:07 +03:00
1 parent 98e4a055fe
commit 72070901ec
8 files changed
+65 -27

No files matched your search

+11 -21
View File
@@ -5,12 +5,14 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="ed1a3c4f-83ac-4211-ae32-004a26afd5d8" name="Changes" comment=""> <list default="true" id="ed1a3c4f-83ac-4211-ae32-004a26afd5d8" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/EntityGUID.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/EntityGUID.cs.meta" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.Infratest/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Infratest/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/.idea.Infratest/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Infratest/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/Entity.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/Entity.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/Entity.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/Entity.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/EntityHealth.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/EntityHealth.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/EntityHealth.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/EntityHealth.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/PlatformerEnemyFactory.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/PlatformerEnemyFactory.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/Resources_moved/Example/Platformer/Characters/Enemies/Boar.prefab" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Resources_moved/Example/Platformer/Characters/Enemies/Boar.prefab" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/PlayerEntity.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/PlayerEntity.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/UnityCodeGen.Generated/ConfigLocator.Generated.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/UnityCodeGen.Generated/ConfigLocator.Generated.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Code/Example/Platformer/PlatformerState.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Code/Example/Platformer/PlatformerState.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/UnityCodeGen.Generated/SystemConfigsReferences.Generated.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/UnityCodeGen.Generated/SystemConfigsReferences.Generated.cs" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -35,6 +37,7 @@
<setting file="file://$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/Enemies/BeeRadar.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/Enemies/BeeRadar.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/Enemies/Snail.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/Enemies/Snail.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/Entity.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/Entity.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/EntityGUID.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/PlatformerEnemyFactory.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/PlatformerEnemyFactory.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/PlayerEntity.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$PROJECT_DIR$/Assets/Code/Example/Platformer/Entity/PlayerEntity.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/Code/Example/Platformer/Level/PlatformerLevelData.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$PROJECT_DIR$/Assets/Code/Example/Platformer/Level/PlatformerLevelData.cs" root0="FORCE_HIGHLIGHTING" />
@@ -291,7 +294,7 @@
<workItem from="1771429673395" duration="3644000" /> <workItem from="1771429673395" duration="3644000" />
<workItem from="1771433586006" duration="1485000" /> <workItem from="1771433586006" duration="1485000" />
<workItem from="1773065611992" duration="4340000" /> <workItem from="1773065611992" duration="4340000" />
<workItem from="1773758943752" duration="396000" /> <workItem from="1773758943752" duration="4321000" />
</task> </task>
<servers /> <servers />
</component> </component>
@@ -325,26 +328,13 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DotNet Breakpoints"> <line-breakpoint enabled="true" type="DotNet Breakpoints">
<url>file://$PROJECT_DIR$/Assets/Code/Example/Platformer/PlatformerSceneInstaller.cs</url> <url>file://$PROJECT_DIR$/Assets/Code/Example/Platformer/PlatformerSceneInstaller.cs</url>
<line>45</line> <line>68</line>
<properties documentPath="$PROJECT_DIR$/Assets/Code/Example/Platformer/PlatformerSceneInstaller.cs" containingFunctionPresentation="Method 'OnContainerBuild'"> <properties documentPath="$PROJECT_DIR$/Assets/Code/Example/Platformer/PlatformerSceneInstaller.cs" containingFunctionPresentation="Method 'Dispose'">
<startOffsets> <startOffsets>
<option value="1817" /> <option value="2442" />
</startOffsets> </startOffsets>
<endOffsets> <endOffsets>
<option value="1840" /> <option value="2491" />
</endOffsets>
</properties>
<option name="timeStamp" value="75" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DotNet Breakpoints">
<url>file://$PROJECT_DIR$/Assets/Code/Example/Platformer/PlatformerSceneInstaller.cs</url>
<line>51</line>
<properties documentPath="$PROJECT_DIR$/Assets/Code/Example/Platformer/PlatformerSceneInstaller.cs" containingFunctionPresentation="Method 'PlatformerEnemyFactoryInitialized'">
<startOffsets>
<option value="1967" />
</startOffsets>
<endOffsets>
<option value="1991" />
</endOffsets> </endOffsets>
</properties> </properties>
<option name="timeStamp" value="77" /> <option name="timeStamp" value="77" />
@@ -1,4 +1,3 @@
using System;
using Code.Infrastructure.Configs; using Code.Infrastructure.Configs;
using UnityEngine; using UnityEngine;
@@ -49,5 +48,8 @@ namespace Code.Example.Platformer.Entity
} }
protected abstract void Move(); protected abstract void Move();
public virtual void OnGetDamage(){}
public virtual void OnDeath(){}
} }
} }
@@ -0,0 +1,24 @@
using System;
using Unity.Collections;
using UnityEngine;
namespace Code.Example.Platformer.Entity
{
public class EntityGUID : MonoBehaviour
{
[SerializeField, ReadOnly] private string _id = GenerateId();
public string Id => _id;
[ContextMenu("Reset Id")]
private void ResetId()
{
_id = GenerateId();
}
private static string GenerateId()
{
return Guid.NewGuid().ToString();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 597458061f454fbc9767838561ac16b6
timeCreated: 1773761214
@@ -1,3 +1,5 @@
using Code.Infrastructure.EventBus;
using Reflex.Attributes;
using UnityEngine; using UnityEngine;
namespace Code.Example.Platformer.Entity namespace Code.Example.Platformer.Entity
@@ -9,11 +11,16 @@ namespace Code.Example.Platformer.Entity
public void SetMaxHealth(int maxHealth) => _maxHealth = maxHealth; public void SetMaxHealth(int maxHealth) => _maxHealth = maxHealth;
public bool IsDead { get; private set; } public bool IsDead { get; private set; }
[Inject] private EventBus _eventBus;
[SerializeField] private Entity entity;
public void GiveDamage(int damage) public void GiveDamage(int damage)
{ {
_health -= damage; _health -= damage;
if(_health <= 0) IsDead = true; if(_health <= 0) IsDead = true;
_eventBus.RaiseEvent<IEntityDamagedHandler>(x=> x.EntityDamaged(gameObject, damage, IsDead));
} }
public void Heal(int heal) public void Heal(int heal)
@@ -21,6 +28,17 @@ namespace Code.Example.Platformer.Entity
if (IsDead) return; if (IsDead) return;
if (_health + heal > _maxHealth) _health = _maxHealth; if (_health + heal > _maxHealth) _health = _maxHealth;
else _health += heal; else _health += heal;
_eventBus.RaiseEvent<IEntityHealedHandler>(x=> x.EntityHealed(gameObject, heal));
} }
} }
public interface IEntityDamagedHandler : IGlobalSubscriber
{
void EntityDamaged(GameObject entity, int damageCount, bool isDied);
}
public interface IEntityHealedHandler : IGlobalSubscriber
{
void EntityHealed(GameObject entity, int healCount);
}
} }
@@ -299,5 +299,6 @@ MonoBehaviour:
animator: {fileID: -3155582984912602300} animator: {fileID: -3155582984912602300}
spriteRenderer: {fileID: 7973072655843182893} spriteRenderer: {fileID: 7973072655843182893}
groundPoint: {x: 0, y: -0.4} groundPoint: {x: 0, y: -0.4}
groundPointadsdassd: 12312
groundLeft: {x: -0.3, y: -0.4} groundLeft: {x: -0.3, y: -0.4}
groundRight: {x: 0.3, y: -0.4} groundRight: {x: 0.3, y: -0.4}
@@ -2,7 +2,6 @@
#pragma warning disable CS0105 #pragma warning disable CS0105
using Code.Infrastructure.Audio; using Code.Infrastructure.Audio;
using Code.Example.Platformer.Entity; using Code.Example.Platformer.Entity;
using Code.Example.Platformer.Entity;
using Code.Infrastructure.Volume; using Code.Infrastructure.Volume;
using Code.Infrastructure.Camera; using Code.Infrastructure.Camera;
using Code.Infrastructure.UI; using Code.Infrastructure.UI;
@@ -10,6 +9,7 @@ using Code.Example.Race.Racer;
using Code.Infrastructure.Configs; using Code.Infrastructure.Configs;
using Code.Infrastructure.Audio; using Code.Infrastructure.Audio;
using Code.Infrastructure.Audio; using Code.Infrastructure.Audio;
using Code.Example.Platformer.Entity;
using Code.Infrastructure.UI; using Code.Infrastructure.UI;
using Code.Infrastructure.SceneLoader; using Code.Infrastructure.SceneLoader;
using Code.Infrastructure.Camera; using Code.Infrastructure.Camera;
@@ -31,8 +31,6 @@ using Code.Infrastructure.Input;
_multipleConfigReferences.Add(typeof(Code.Example.Platformer.Entity.PlatformerEntitySettingsConfig), systemConfigsReferences.PlatformerEntitySettings); _multipleConfigReferences.Add(typeof(Code.Example.Platformer.Entity.PlatformerEntitySettingsConfig), systemConfigsReferences.PlatformerEntitySettings);
_singleConfigReferences.Add(typeof(Code.Example.Platformer.Entity.PlatformerPlayerSettingsConfig), systemConfigsReferences.PlatformerPlayerSettings);
_multipleConfigReferences.Add(typeof(Code.Infrastructure.Volume.VolumeSettingsConfig), systemConfigsReferences.VolumeSettings); _multipleConfigReferences.Add(typeof(Code.Infrastructure.Volume.VolumeSettingsConfig), systemConfigsReferences.VolumeSettings);
_singleConfigReferences.Add(typeof(Code.Infrastructure.Camera.GameCameraConfig), systemConfigsReferences.GameCamera); _singleConfigReferences.Add(typeof(Code.Infrastructure.Camera.GameCameraConfig), systemConfigsReferences.GameCamera);
@@ -47,6 +45,8 @@ using Code.Infrastructure.Input;
_singleConfigReferences.Add(typeof(Code.Infrastructure.Audio.AudioSourcePrefabConfig), systemConfigsReferences.AudioSourcePrefab); _singleConfigReferences.Add(typeof(Code.Infrastructure.Audio.AudioSourcePrefabConfig), systemConfigsReferences.AudioSourcePrefab);
_singleConfigReferences.Add(typeof(Code.Example.Platformer.Entity.PlatformerPlayerSettingsConfig), systemConfigsReferences.PlatformerPlayerSettings);
_singleConfigReferences.Add(typeof(Code.Infrastructure.UI.CanvasSettingsConfig), systemConfigsReferences.CanvasSettings); _singleConfigReferences.Add(typeof(Code.Infrastructure.UI.CanvasSettingsConfig), systemConfigsReferences.CanvasSettings);
_multipleConfigReferences.Add(typeof(Code.Infrastructure.SceneLoader.SceneInfoConfig), systemConfigsReferences.SceneInfo); _multipleConfigReferences.Add(typeof(Code.Infrastructure.SceneLoader.SceneInfoConfig), systemConfigsReferences.SceneInfo);
@@ -2,7 +2,6 @@
#pragma warning disable CS0105 #pragma warning disable CS0105
using Code.Infrastructure.Audio; using Code.Infrastructure.Audio;
using Code.Example.Platformer.Entity; using Code.Example.Platformer.Entity;
using Code.Example.Platformer.Entity;
using Code.Infrastructure.Volume; using Code.Infrastructure.Volume;
using Code.Infrastructure.Camera; using Code.Infrastructure.Camera;
using Code.Infrastructure.UI; using Code.Infrastructure.UI;
@@ -10,6 +9,7 @@ using Code.Example.Race.Racer;
using Code.Infrastructure.Configs; using Code.Infrastructure.Configs;
using Code.Infrastructure.Audio; using Code.Infrastructure.Audio;
using Code.Infrastructure.Audio; using Code.Infrastructure.Audio;
using Code.Example.Platformer.Entity;
using Code.Infrastructure.UI; using Code.Infrastructure.UI;
using Code.Infrastructure.SceneLoader; using Code.Infrastructure.SceneLoader;
using Code.Infrastructure.Camera; using Code.Infrastructure.Camera;
@@ -23,7 +23,6 @@ using Code.Infrastructure.Input;
{ {
public string AudioInfo; public string AudioInfo;
public string PlatformerEntitySettings; public string PlatformerEntitySettings;
public AssetReference PlatformerPlayerSettings;
public string VolumeSettings; public string VolumeSettings;
public AssetReference GameCamera; public AssetReference GameCamera;
public string UIPanelSettings; public string UIPanelSettings;
@@ -31,6 +30,7 @@ public string RacerSettings;
public string LayerMasksConfig; public string LayerMasksConfig;
public string AudioSourceSettings; public string AudioSourceSettings;
public AssetReference AudioSourcePrefab; public AssetReference AudioSourcePrefab;
public AssetReference PlatformerPlayerSettings;
public AssetReference CanvasSettings; public AssetReference CanvasSettings;
public string SceneInfo; public string SceneInfo;
public string CameraSettings; public string CameraSettings;