Browse Source

Bolt Performance Fix

bolt_update
laurids 3 years ago
parent
commit
9ad368476a
8 changed files with 95 additions and 36 deletions
  1. +6
    -6
      Assets/GWConquest/Scripts/BattleFlank.cs
  2. +53
    -0
      Assets/GWConquest/Scripts/BoltEntityCache.cs
  3. +11
    -0
      Assets/GWConquest/Scripts/BoltEntityCache.cs.meta
  4. +11
    -17
      Assets/GWConquest/Scripts/Formation.cs
  5. +4
    -3
      Assets/GWConquest/Scripts/Unit.cs
  6. BIN
      Assets/Photon/PhotonBolt/assemblies/bolt.user.dll
  7. BIN
      Assets/Photon/PhotonBolt/assemblies/bolt.user.dll.mdb
  8. +10
    -10
      Assets/Photon/PhotonBolt/project.json

+ 6
- 6
Assets/GWConquest/Scripts/BattleFlank.cs View File

@ -12,8 +12,8 @@ namespace GWConquest {
public BattleFlankUI CurrentUI;
public Battle Battle {
get => State.Battle?.GetComponent<Battle>();
set => State.Battle = value?.entity;
get => BoltEntityCache.Get<Battle>(State.Battle);
set => State.Battle = BoltEntityCache.Set(value);
}
public int FlankId {
@ -29,13 +29,13 @@ namespace GWConquest {
}
public BattleFlank OpposingFlank {
get => State.OpposingFlank?.GetComponent<BattleFlank>();
set => State.OpposingFlank = value?.entity;
get => BoltEntityCache.Get<BattleFlank>(State.OpposingFlank);
set => State.OpposingFlank = BoltEntityCache.Set(value);
}
public Player Player {
get => State.Player?.GetComponent<Player>();
set => State.Player = value?.entity;
get => BoltEntityCache.Get<Player>(State.Player);
set => State.Player = BoltEntityCache.Set(value);
}
public Unit GetUnit(int index) {


+ 53
- 0
Assets/GWConquest/Scripts/BoltEntityCache.cs View File

@ -0,0 +1,53 @@
using Bolt;
using UnityEngine;
using System.Collections.Generic;
namespace GWConquest
{
public static class BoltEntityCache
{
private static Dictionary<NetworkId, IEntityBehaviour> dictionary = new Dictionary<NetworkId, IEntityBehaviour>();
public static T Get<T>(NetworkId id) where T : class, IEntityBehaviour
{
if(id == default(NetworkId))
{
return null;
}
if(dictionary.ContainsKey(id))
{
var behaviour = dictionary[id];
if(behaviour.entity.NetworkId == id)
{
return behaviour as T;
}
}
var entity = BoltNetwork.FindEntity(id);
if(entity == null)
{
return null;
}
else {
var newBeh = entity.GetComponent<T>();
dictionary[id] = newBeh;
return newBeh;
}
}
public static NetworkId Set<T>(T behaviour) where T : class, IEntityBehaviour
{
if(behaviour == null)
{
return default(NetworkId);
}
else {
return behaviour.entity.NetworkId;
}
}
}
}

+ 11
- 0
Assets/GWConquest/Scripts/BoltEntityCache.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c2f033f40a5a03e4ba66c6f9240d2043
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 11
- 17
Assets/GWConquest/Scripts/Formation.cs View File

@ -50,14 +50,8 @@ namespace GWConquest
public Player Player
{
get
{
return State.Player?.GetComponent<Player>();
}
set
{
State.Player = value.entity;
}
get => BoltEntityCache.Get<Player>(State.Player);
set => State.Player = BoltEntityCache.Set(value);
}
public string FormationName
@ -96,8 +90,8 @@ namespace GWConquest
public Unit HeroUnit
{
get => State.HeroUnit?.GetComponent<Unit>();
set => State.HeroUnit = value.entity;
get => BoltEntityCache.Get<Unit>(State.HeroUnit);
set => State.HeroUnit = BoltEntityCache.Set(value);
}
public IEnumerable<ItemStack> AllItems
@ -113,13 +107,13 @@ namespace GWConquest
public ZoneList PathQueue;
public Formation MovementTargetFormation {
get => State.MovementTargetFormation?.GetComponent<Formation>();
set => State.MovementTargetFormation = value?.entity;
get => BoltEntityCache.Get<Formation>(State.MovementTargetFormation);
set => State.MovementTargetFormation = BoltEntityCache.Set(value);
}
public Formation MovementOriginFormation {
get => State.MovementOriginFormation?.GetComponent<Formation>();
set => State.MovementOriginFormation = value?.entity;
get => BoltEntityCache.Get<Formation>(State.MovementOriginFormation);
set => State.MovementOriginFormation = BoltEntityCache.Set(value);
}
public bool IsOnSpaceGroundTransition
@ -133,8 +127,8 @@ namespace GWConquest
}
public Formation ParentFormation {
get => State.ParentFormation?.GetComponent<Formation>();
set => State.ParentFormation = value?.entity;
get => BoltEntityCache.Get<Formation>(State.ParentFormation);
set => State.ParentFormation = BoltEntityCache.Set(value);
}
public const float MoraleCap = 27 * 3 * 100;
@ -254,7 +248,7 @@ namespace GWConquest
}
if(evnt.TargetFormation != null)
{
State.MovementTargetFormation = evnt.TargetFormation;
State.MovementTargetFormation = evnt.TargetFormation.NetworkId;
}
SetActionCooldown(GameManager.Instance.MovementStartingCooldown);


+ 4
- 3
Assets/GWConquest/Scripts/Unit.cs View File

@ -34,8 +34,8 @@ namespace GWConquest
public Formation Formation
{
get => State.Formation?.GetComponent<Formation>();
set => State.Formation = value.entity;
get => BoltEntityCache.Get<Formation>(State.Formation);
set => State.Formation = BoltEntityCache.Set(value);
}
public int Hitpoints {
@ -288,7 +288,8 @@ namespace GWConquest
public override void SimulateOwner()
{
if(!IsDead && CurrentBattle != null && !CurrentBattle.IsInPreparing)
var battle = CurrentBattle;
if(!IsDead && battle != null && !battle.IsInPreparing)
{
if(BattleState == BattleUnitState.Arriving)
{


BIN
Assets/Photon/PhotonBolt/assemblies/bolt.user.dll View File


BIN
Assets/Photon/PhotonBolt/assemblies/bolt.user.dll.mdb View File


+ 10
- 10
Assets/Photon/PhotonBolt/project.json View File

@ -65,7 +65,7 @@
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
"$type": "Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyStateSettings, bolt.compiler",
@ -116,7 +116,7 @@
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
"$type": "Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyStateSettings, bolt.compiler",
@ -133,7 +133,7 @@
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
"$type": "Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyStateSettings, bolt.compiler",
@ -203,7 +203,7 @@
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
"$type": "Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyStateSettings, bolt.compiler",
@ -220,7 +220,7 @@
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
"$type": "Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyStateSettings, bolt.compiler",
@ -254,7 +254,7 @@
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
"$type": "Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyStateSettings, bolt.compiler",
@ -881,7 +881,7 @@
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
"$type": "Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyStateSettings, bolt.compiler",
@ -1668,7 +1668,7 @@
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
"$type": "Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyStateSettings, bolt.compiler",
@ -1721,7 +1721,7 @@
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
"$type": "Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyStateSettings, bolt.compiler",
@ -1759,7 +1759,7 @@
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
"$type": "Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyStateSettings, bolt.compiler",


Loading…
Cancel
Save