Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stats rewrite #144

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Assets/Scripts/Characters/BaseCharacter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public virtual void GetHitRPC(int viewId, string name, int damage, string type,
name = killer.Name;
}
TakeDamage(damage);
Cache.PhotonView.RPC("NotifyDamagedRPC", RpcTarget.All, new object[] { viewId, name, damage });
Cache.PhotonView.RPC(nameof(NotifyDamagedRPC), RpcTarget.All, new object[] { viewId, name, damage });
if (CurrentHealth <= 0f)
{
RPCManager.PhotonView.RPC("ShowKillFeedRPC", RpcTarget.All, new object[] { name, Name, damage, type});
Expand All @@ -355,7 +355,7 @@ public virtual void GetDamagedRPC(string name, int damage)
if (!Cache.PhotonView.IsMine || Dead)
return;
TakeDamage(damage);
Cache.PhotonView.RPC("NotifyDamagedRPC", RpcTarget.All, new object[] { -1, name, damage });
Cache.PhotonView.RPC(nameof(NotifyDamagedRPC), RpcTarget.All, new object[] { -1, name, damage });
if (CurrentHealth <= 0f)
{
RPCManager.PhotonView.RPC("ShowKillFeedRPC", RpcTarget.All, new object[] { name, Name, damage, "" });
Expand Down Expand Up @@ -434,13 +434,13 @@ public virtual void GetHit(BaseCharacter enemy, int damage, string type, string
int viewId = -1;
if (enemy != null)
viewId = enemy.Cache.PhotonView.ViewID;
Cache.PhotonView.RPC("GetHitRPC", Cache.PhotonView.Owner, new object[] { viewId, "", damage, type, collider });
Cache.PhotonView.RPC(nameof(GetHitRPC), Cache.PhotonView.Owner, new object[] { viewId, "", damage, type, collider });
}

public virtual void GetHit(string name, int damage, string type, string collider)
{
if (!Dead)
Cache.PhotonView.RPC("GetHitRPC", Cache.PhotonView.Owner, new object[] { -1, name, damage, type, collider });
Cache.PhotonView.RPC(nameof(GetHitRPC), Cache.PhotonView.Owner, new object[] { -1, name, damage, type, collider });
}

public virtual void GetDamaged(string name, int damage)
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Characters/Human/Human.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ protected void FixedUpdate()
}
}
_currentVelocity = Cache.Rigidbody.velocity;
GameProgressManager.RegisterSpeed(gameObject, _currentVelocity.magnitude);
GameProgressManager.RegisterSpeed(_currentVelocity.magnitude);
Cache.Transform.rotation = Quaternion.Lerp(Cache.Transform.rotation, _targetRotation, Time.deltaTime * 10f);
CheckGround();
bool pivotLeft = FixedUpdateLaunch(true);
Expand Down
8 changes: 4 additions & 4 deletions Assets/Scripts/Characters/Human/HumanSpecials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace Characters
{
class HumanSpecials
{
private static string[] AnySpecials = new string[] {"Potato", "Escape", "Dance", "Distract", "Smell", "Supply", "SmokeBomb", "Carry", "Switchback"};
private static string[] AHSSSpecials = new string[] { "AHSSTwinShot" };
private static string[] BladeSpecials = new string[] { "DownStrike", "Spin1", "Spin2", "Spin3", "BladeThrow" };
private static string[] ShifterSpecials = new string[] { "Eren", "Annie" };
public static string[] AnySpecials = new string[] {"Potato", "Escape", "Dance", "Distract", "Smell", "Supply", "SmokeBomb", "Carry", "Switchback"};
public static string[] AHSSSpecials = new string[] { "AHSSTwinShot" };
public static string[] BladeSpecials = new string[] { "DownStrike", "Spin1", "Spin2", "Spin3", "BladeThrow" };
public static string[] ShifterSpecials = new string[] { "Eren", "Annie" };

public static readonly string DefaultSpecial = "Potato";

Expand Down
51 changes: 6 additions & 45 deletions Assets/Scripts/GameManagers/InGameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,60 +213,21 @@ public void RegisterMainCharacterDie()
PhotonNetwork.LocalPlayer.SetCustomProperty(PlayerProperty.Deaths, PhotonNetwork.LocalPlayer.GetIntProperty(PlayerProperty.Deaths) + 1);
}

public void RegisterMainCharacterKill(BaseCharacter victim)
public void RegisterMainCharacterKill(BaseCharacter enemy)
{
if (CurrentCharacter == null)
return;
var killWeapon = KillWeapon.Other;
if (CurrentCharacter is Human)
{
var human = (Human)CurrentCharacter;
if (human.Setup.Weapon == HumanWeapon.AHSS)
killWeapon = KillWeapon.AHSS;
else if (human.Setup.Weapon == HumanWeapon.Blade)
killWeapon = KillWeapon.Blade;
else if (human.Setup.Weapon == HumanWeapon.Thunderspear)
killWeapon = KillWeapon.Thunderspear;
else if (human.Setup.Weapon == HumanWeapon.APG)
killWeapon = KillWeapon.APG;
}
else if (CurrentCharacter is BasicTitan)
killWeapon = KillWeapon.Titan;
else if (CurrentCharacter is BaseShifter)
killWeapon = KillWeapon.Shifter;
if (victim is Human)
GameProgressManager.RegisterHumanKill(CurrentCharacter.gameObject, (Human)victim, killWeapon);
else if (victim is BasicTitan)
GameProgressManager.RegisterTitanKill(CurrentCharacter.gameObject, (BasicTitan)victim, killWeapon);
if (CurrentCharacter == null) return;
GameProgressManager.RegisterKill(CurrentCharacter, enemy);
var properties = new Dictionary<string, object>
{
{ PlayerProperty.Kills, PhotonNetwork.LocalPlayer.GetIntProperty(PlayerProperty.Kills) + 1 }
};
PhotonNetwork.LocalPlayer.SetCustomProperties(properties);
}

public void RegisterMainCharacterDamage(BaseCharacter victim, int damage)
public void RegisterMainCharacterDamage(BaseCharacter enemy, int damage)
{
if (CurrentCharacter == null)
return;
var killWeapon = KillWeapon.Other;
if (CurrentCharacter is Human)
{
var human = (Human)CurrentCharacter;
if (human.Setup.Weapon == HumanWeapon.AHSS)
killWeapon = KillWeapon.AHSS;
else if (human.Setup.Weapon == HumanWeapon.Blade)
killWeapon = KillWeapon.Blade;
else if (human.Setup.Weapon == HumanWeapon.Thunderspear)
killWeapon = KillWeapon.Thunderspear;
else if (human.Setup.Weapon == HumanWeapon.APG)
killWeapon = KillWeapon.APG;
}
else if (CurrentCharacter is BasicTitan)
killWeapon = KillWeapon.Titan;
else if (CurrentCharacter is BaseShifter)
killWeapon = KillWeapon.Shifter;
GameProgressManager.RegisterDamage(CurrentCharacter.gameObject, victim.gameObject, killWeapon, damage);
if (CurrentCharacter == null) return;
GameProgressManager.RegisterDamage(CurrentCharacter, enemy, damage);
var properties = new Dictionary<string, object>
{
{ PlayerProperty.TotalDamage, PhotonNetwork.LocalPlayer.GetIntProperty(PlayerProperty.TotalDamage) + damage },
Expand Down
11 changes: 4 additions & 7 deletions Assets/Scripts/GameProgress/BaseGameProgressHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@ namespace GameProgress
{
abstract class BaseGameProgressHandler
{
public virtual void RegisterTitanKill(GameObject character, BasicTitan victim, KillWeapon weapon)
public virtual void RegisterKill(BaseCharacter player, BaseCharacter enemy)
{
}
public virtual void RegisterHumanKill(GameObject character, Human victim, KillWeapon weapon)
public virtual void RegisterDamage(BaseCharacter player, BaseCharacter enemy, int damage)
{
}
public virtual void RegisterDamage(GameObject character, GameObject victim, KillWeapon weapon, int damage)
public virtual void RegisterSpeed(float speed)
{
}
public virtual void RegisterSpeed(GameObject character, float speed)
{
}
public virtual void RegisterInteraction(GameObject character, GameObject interact, InteractionType interactionType)
public virtual void RegisterInteraction(GameObject interact, InteractionType interactionType)
{
}
}
Expand Down
8 changes: 8 additions & 0 deletions Assets/Scripts/GameProgress/Codegen.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 104 additions & 0 deletions Assets/Scripts/GameProgress/Codegen/Enemies.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>

namespace GameProgress.Codegen
{

using global::System;
using global::System.Collections.Generic;
using global::Google.FlatBuffers;

public struct Enemies : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_24_3_25(); }
public static Enemies GetRootAsEnemies(ByteBuffer _bb) { return GetRootAsEnemies(_bb, new Enemies()); }
public static Enemies GetRootAsEnemies(ByteBuffer _bb, Enemies obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
public Enemies __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }

public GameProgress.Codegen.Weapons? Human { get { int o = __p.__offset(4); return o != 0 ? (GameProgress.Codegen.Weapons?)(new GameProgress.Codegen.Weapons()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } }
public GameProgress.Codegen.Weapons? Titan { get { int o = __p.__offset(6); return o != 0 ? (GameProgress.Codegen.Weapons?)(new GameProgress.Codegen.Weapons()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } }
public GameProgress.Codegen.Weapons? Shifter { get { int o = __p.__offset(8); return o != 0 ? (GameProgress.Codegen.Weapons?)(new GameProgress.Codegen.Weapons()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } }
public GameProgress.Codegen.Weapons? Other { get { int o = __p.__offset(10); return o != 0 ? (GameProgress.Codegen.Weapons?)(new GameProgress.Codegen.Weapons()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } }

public static Offset<GameProgress.Codegen.Enemies> CreateEnemies(FlatBufferBuilder builder,
Offset<GameProgress.Codegen.Weapons> humanOffset = default(Offset<GameProgress.Codegen.Weapons>),
Offset<GameProgress.Codegen.Weapons> titanOffset = default(Offset<GameProgress.Codegen.Weapons>),
Offset<GameProgress.Codegen.Weapons> shifterOffset = default(Offset<GameProgress.Codegen.Weapons>),
Offset<GameProgress.Codegen.Weapons> otherOffset = default(Offset<GameProgress.Codegen.Weapons>)) {
builder.StartTable(4);
Enemies.AddOther(builder, otherOffset);
Enemies.AddShifter(builder, shifterOffset);
Enemies.AddTitan(builder, titanOffset);
Enemies.AddHuman(builder, humanOffset);
return Enemies.EndEnemies(builder);
}

public static void StartEnemies(FlatBufferBuilder builder) { builder.StartTable(4); }
public static void AddHuman(FlatBufferBuilder builder, Offset<GameProgress.Codegen.Weapons> humanOffset) { builder.AddOffset(0, humanOffset.Value, 0); }
public static void AddTitan(FlatBufferBuilder builder, Offset<GameProgress.Codegen.Weapons> titanOffset) { builder.AddOffset(1, titanOffset.Value, 0); }
public static void AddShifter(FlatBufferBuilder builder, Offset<GameProgress.Codegen.Weapons> shifterOffset) { builder.AddOffset(2, shifterOffset.Value, 0); }
public static void AddOther(FlatBufferBuilder builder, Offset<GameProgress.Codegen.Weapons> otherOffset) { builder.AddOffset(3, otherOffset.Value, 0); }
public static Offset<GameProgress.Codegen.Enemies> EndEnemies(FlatBufferBuilder builder) {
int o = builder.EndTable();
return new Offset<GameProgress.Codegen.Enemies>(o);
}
public EnemiesT UnPack() {
var _o = new EnemiesT();
this.UnPackTo(_o);
return _o;
}
public void UnPackTo(EnemiesT _o) {
_o.Human = this.Human.HasValue ? this.Human.Value.UnPack() : null;
_o.Titan = this.Titan.HasValue ? this.Titan.Value.UnPack() : null;
_o.Shifter = this.Shifter.HasValue ? this.Shifter.Value.UnPack() : null;
_o.Other = this.Other.HasValue ? this.Other.Value.UnPack() : null;
}
public static Offset<GameProgress.Codegen.Enemies> Pack(FlatBufferBuilder builder, EnemiesT _o) {
if (_o == null) return default(Offset<GameProgress.Codegen.Enemies>);
var _human = _o.Human == null ? default(Offset<GameProgress.Codegen.Weapons>) : GameProgress.Codegen.Weapons.Pack(builder, _o.Human);
var _titan = _o.Titan == null ? default(Offset<GameProgress.Codegen.Weapons>) : GameProgress.Codegen.Weapons.Pack(builder, _o.Titan);
var _shifter = _o.Shifter == null ? default(Offset<GameProgress.Codegen.Weapons>) : GameProgress.Codegen.Weapons.Pack(builder, _o.Shifter);
var _other = _o.Other == null ? default(Offset<GameProgress.Codegen.Weapons>) : GameProgress.Codegen.Weapons.Pack(builder, _o.Other);
return CreateEnemies(
builder,
_human,
_titan,
_shifter,
_other);
}
}

public class EnemiesT
{
public GameProgress.Codegen.WeaponsT Human { get; set; }
public GameProgress.Codegen.WeaponsT Titan { get; set; }
public GameProgress.Codegen.WeaponsT Shifter { get; set; }
public GameProgress.Codegen.WeaponsT Other { get; set; }

public EnemiesT() {
this.Human = null;
this.Titan = null;
this.Shifter = null;
this.Other = null;
}
}


static public class EnemiesVerify
{
static public bool Verify(Google.FlatBuffers.Verifier verifier, uint tablePos)
{
return verifier.VerifyTableStart(tablePos)
&& verifier.VerifyTable(tablePos, 4 /*Human*/, GameProgress.Codegen.WeaponsVerify.Verify, false)
&& verifier.VerifyTable(tablePos, 6 /*Titan*/, GameProgress.Codegen.WeaponsVerify.Verify, false)
&& verifier.VerifyTable(tablePos, 8 /*Shifter*/, GameProgress.Codegen.WeaponsVerify.Verify, false)
&& verifier.VerifyTable(tablePos, 10 /*Other*/, GameProgress.Codegen.WeaponsVerify.Verify, false)
&& verifier.VerifyTableEnd(tablePos);
}
}

}
11 changes: 11 additions & 0 deletions Assets/Scripts/GameProgress/Codegen/Enemies.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 96 additions & 0 deletions Assets/Scripts/GameProgress/Codegen/GameProgress.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
namespace GameProgress.Codegen;

file_identifier "AOT2";

// maps.forest1.survival.titan.
table Maps {
// General
forest1:Modes;
forest2:Modes;
forest3:Modes;
city1:Modes;
city2:Modes;
utgard1:Modes;
utgard2:Modes;
cave1:Modes;
lake:Modes;
plaza:Modes;
grandmaster:Modes;
casino:Modes;
forest_flooded:Modes;
forest_lava:Modes;
deforest1:Modes;
birth_of_levi:Modes;
mews_1k:Modes;
rocky_mountain:Modes;
shiganshina:Modes;
trost:Modes;
futuristic_forest:Modes;
other:[NamedMap];
}

table NamedMap {
name:string;
modes:Modes;
}

table Modes {
ahss_pvp:Enemies;
apg_pvp:Enemies;
base:Enemies;
blade_pvp:Enemies;
cage_fight:Enemies;
cranked:Enemies;
endless:Enemies;
none:Enemies;
racing:Enemies;
survive:Enemies;
thunderspear_pvp:Enemies;
titan_explode:Enemies;
waves:Enemies;
other:[NamedMode];
}

table NamedMode {
name:string;
enemies:Enemies;
}

table Enemies {
human:Weapons;
titan:Weapons;
shifter:Weapons;
other:Weapons;
}

table Weapons {
blade:Specials;
ahss:Specials;
thunderspear:Specials;
apg:Specials;
titan:Specials;
shifter:Specials;
other:Specials;
}

table Specials {
none:Metrics;
downstrike:Metrics;
spin1:Metrics;
spin2:Metrics;
spin3:Metrics;
bladethrow:Metrics;
twinshot:Metrics;
stock:Metrics;
eren:Metrics;
annie:Metrics;
other:Metrics;
}

table Metrics {
kills:uint32;
total_damage:uint64;
highest_damage:uint32;
}

root_type Maps;
7 changes: 7 additions & 0 deletions Assets/Scripts/GameProgress/Codegen/GameProgress.fbs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading