Browse Source

Performance: District loop, Fixes

master
laurids 2 years ago
parent
commit
31bb404279
8 changed files with 101 additions and 82 deletions
  1. +22
    -8
      Assets/GWConquest/Scripts/District.cs
  2. +74
    -69
      Assets/GWConquest/Scripts/Formation.cs
  3. +1
    -1
      Assets/GWConquest/Scripts/Planet.cs
  4. +1
    -1
      Assets/GWConquest/Scripts/PlanetPlacement.cs
  5. BIN
      Assets/Photon/PhotonBolt/assemblies/bolt.user.dll
  6. BIN
      Assets/Photon/PhotonBolt/assemblies/bolt.user.dll.mdb
  7. +1
    -1
      Assets/Photon/PhotonBolt/project.json
  8. +2
    -2
      Assets/Photon/PhotonBolt/resources/BoltRuntimeSettings.asset

+ 22
- 8
Assets/GWConquest/Scripts/District.cs View File

@ -37,10 +37,7 @@ namespace GWConquest
return type == DistrictType.Civil || type == DistrictType.SpaceStation || type == DistrictType.FactoryArmor || type == DistrictType.FactoryInfantry || type == DistrictType.FactorySupplies || type == DistrictType.FactoryFuel; return type == DistrictType.Civil || type == DistrictType.SpaceStation || type == DistrictType.FactoryArmor || type == DistrictType.FactoryInfantry || type == DistrictType.FactorySupplies || type == DistrictType.FactoryFuel;
} }
public Planet Planet {
get => State.Planet?.GetComponent<Planet>();
set => State.Planet = value.entity;
}
public Planet Planet;
public Player ControllingPlayer { public Player ControllingPlayer {
get { get {
@ -105,13 +102,17 @@ namespace GWConquest
State.DistrictType = (int) DistrictType; State.DistrictType = (int) DistrictType;
State.DistrictName = DistrictName; State.DistrictName = DistrictName;
State.Level = DistrictLevel; State.Level = DistrictLevel;
State.Planet = GetComponentInParent<Planet>().entity;
} }
Planet = GetComponentInParent<Planet>();
} }
} }
public void InitNonStatic() public void InitNonStatic()
{ {
Planet = BoltEntityCache.Get<Planet>(State.Planet);
if(DistrictType == DistrictType.SpaceStation) if(DistrictType == DistrictType.SpaceStation)
{ {
Zone.zoneType = ZoneType.Space; Zone.zoneType = ZoneType.Space;
@ -212,10 +213,23 @@ namespace GWConquest
public override void SimulateOwner() public override void SimulateOwner()
{ {
var allPlayers = Zone.Formations.Select(f => f.Player).Distinct();
if(allPlayers.Count() == 1)
Player player = null;
bool moreThanOnePlayer = false;
foreach(var f in Zone.Formations)
{
var formationPlayer = f.Player;
if(player == null)
{
player = formationPlayer;
}
else if(player != formationPlayer)
{
moreThanOnePlayer = true;
break;
}
}
if(player != null && !moreThanOnePlayer)
{ {
var player = allPlayers.First();
if(player != ControllingPlayer) if(player != ControllingPlayer)
{ {
BoltLog.Info("Player {0} is the only player in district {1}, changing allegiance", player, this); BoltLog.Info("Player {0} is the only player in district {1}, changing allegiance", player, this);


+ 74
- 69
Assets/GWConquest/Scripts/Formation.cs View File

@ -514,37 +514,39 @@ namespace GWConquest
private void Update() private void Update()
{ {
if(GameManager.EntitiesLoaded)
if (entity.IsAttached)
{ {
if(currentZone != null && currentZone.zoneType == ZoneType.Space && movingArmyIcon == null)
if (GameManager.EntitiesLoaded)
{ {
MakeMovingIcon(IngameUI.Instance.MovingFleetsTransform);
if (currentZone != null && currentZone.zoneType == ZoneType.Space && movingArmyIcon == null)
{
MakeMovingIcon(IngameUI.Instance.MovingFleetsTransform);
}
} }
}
//Debug.LogFormat("Current state: IsInTransit {0}; CurrentZone {1}; CoveredDistance {2}", State.IsInTransit, State.CurrentZone, CoveredDistance);
//Debug.LogFormat("Current state: IsInTransit {0}; CurrentZone {1}; CoveredDistance {2}", State.IsInTransit, State.CurrentZone, CoveredDistance);
if (MovementState == FormationMovementState.Moving)
{
animDistanceCovered += movementSpeed * Time.deltaTime;
Zone originZone = Zone.GetFromId(State.CurrentTransition.OriginZone);
Zone targetZone = Zone.GetFromId(State.CurrentTransition.TargetZone);
if (MovementState == FormationMovementState.Moving)
{
animDistanceCovered += movementSpeed * Time.deltaTime;
Zone originZone = Zone.GetFromId(State.CurrentTransition.OriginZone);
Zone targetZone = Zone.GetFromId(State.CurrentTransition.TargetZone);
Vector3 originPos = originZone.transform.position;
Vector3 targetPos = targetZone.transform.position;
Vector3 originPos = originZone.transform.position;
Vector3 targetPos = targetZone.transform.position;
if(!State.CurrentTransition.IsCurved)
{
originPos += originZone.planet.GetFleetArrivalPosition(targetZone) * originZone.planet.GetCurrentCircleRadius();
targetPos += targetZone.planet.GetFleetArrivalPosition(originZone) * targetZone.planet.GetCurrentCircleRadius();
if (!State.CurrentTransition.IsCurved)
{
originPos += originZone.planet.GetFleetArrivalPosition(targetZone) * originZone.planet.GetCurrentCircleRadius();
targetPos += targetZone.planet.GetFleetArrivalPosition(originZone) * targetZone.planet.GetCurrentCircleRadius();
}
}
Vector3 oldPos = transform.position;
Vector3 newPos;
Quaternion newRot;
//if(State.CurrentTransition.IsCurved)
//{
Vector3 oldPos = transform.position;
Vector3 newPos;
Quaternion newRot;
//if(State.CurrentTransition.IsCurved)
//{
/*Vector3 planetPos = targetZone.planet.transform.position; /*Vector3 planetPos = targetZone.planet.transform.position;
Vector3 originPos = originZone.transform.position - planetPos; Vector3 originPos = originZone.transform.position - planetPos;
Vector3 targetPos = targetZone.transform.position - planetPos; Vector3 targetPos = targetZone.transform.position - planetPos;
@ -553,67 +555,70 @@ namespace GWConquest
newPos += planetPos; newPos += planetPos;
newRot = Quaternion.LookRotation(newPos - oldPos, newPos - planetPos); newRot = Quaternion.LookRotation(newPos - oldPos, newPos - planetPos);
*/ */
//}
//else
//{
//}
//else
//{
newPos = Vector3.Lerp(originPos, newPos = Vector3.Lerp(originPos,
targetPos, targetPos,
animDistanceCovered / State.CurrentTransition.TransitionLength); animDistanceCovered / State.CurrentTransition.TransitionLength);
newRot = Quaternion.LookRotation(newPos - oldPos, Vector3.up); newRot = Quaternion.LookRotation(newPos - oldPos, Vector3.up);
//}
transform.position = newPos;
transform.rotation = newRot;
}
else if(MovementState == FormationMovementState.PreparingMovement)
{
if(ZoneType == ZoneType.Space)
{
var planet = currentZone.planet;
Vector3 origin = GetRestingPosition();
var targetZone = PathQueue.First();
Vector3 target = planet.transform.position + planet.GetFleetArrivalPosition(targetZone) * planet.GetCurrentCircleRadius();
//}
Vector3 newPos = Vector3.Lerp(origin, target, 1f - ActionCooldownPercent);
transform.position = newPos; transform.position = newPos;
transform.rotation = newRot;
} }
}
else if(MovementState == FormationMovementState.FinishingMovement)
{
if(ZoneType == ZoneType.Space)
else if (MovementState == FormationMovementState.PreparingMovement)
{ {
var planet = currentZone.planet;
Vector3 target = GetRestingPosition();
Vector3 origin = planet.transform.position + arrivalPosition * planet.GetCurrentCircleRadius();
if (ZoneType == ZoneType.Space)
{
var planet = currentZone.planet;
Vector3 origin = GetRestingPosition();
var targetZone = PathQueue.First();
Vector3 target = planet.transform.position + planet.GetFleetArrivalPosition(targetZone) * planet.GetCurrentCircleRadius();
Vector3 newPos = Vector3.Lerp(origin, target, 1f - ActionCooldownPercent);
transform.position = newPos;
}
Vector3 newPos = Vector3.Lerp(origin, target, 1f - ActionCooldownPercent);
transform.position = newPos;
} }
}
else if(MovementState == FormationMovementState.Idle)
{
//transform.position = currentZone.transform.position;
if(ZoneType == ZoneType.Space)
else if (MovementState == FormationMovementState.FinishingMovement)
{ {
transform.position = GetRestingPosition();
if (ZoneType == ZoneType.Space)
{
var planet = currentZone.planet;
Vector3 target = GetRestingPosition();
Vector3 origin = planet.transform.position + arrivalPosition * planet.GetCurrentCircleRadius();
Vector3 newPos = Vector3.Lerp(origin, target, 1f - ActionCooldownPercent);
transform.position = newPos;
}
} }
else {
transform.position = currentZone.transform.position;
else if (MovementState == FormationMovementState.Idle)
{
//transform.position = currentZone.transform.position;
if (ZoneType == ZoneType.Space)
{
transform.position = GetRestingPosition();
}
else
{
transform.position = currentZone.transform.position;
}
} }
}
if(movingArmyIcon != null && ZoneType == ZoneType.Space)
{
if(!IngameUI.PlanetViewEnabled && (GWCamera.Instance.ShowCircles || MovementState == FormationMovementState.Moving))
if (movingArmyIcon != null && ZoneType == ZoneType.Space)
{ {
movingArmyIcon.SetActive(true);
movingArmyIcon.GetComponent<StickToFormation>().Update();
}
else {
movingArmyIcon.SetActive(false);
if (!IngameUI.PlanetViewEnabled && (GWCamera.Instance.ShowCircles || MovementState == FormationMovementState.Moving))
{
movingArmyIcon.SetActive(true);
movingArmyIcon.GetComponent<StickToFormation>().Update();
}
else
{
movingArmyIcon.SetActive(false);
}
} }
} }
} }


+ 1
- 1
Assets/GWConquest/Scripts/Planet.cs View File

@ -496,7 +496,7 @@ namespace GWConquest
CircleTransform.localScale = Vector3.one * CircleSize; CircleTransform.localScale = Vector3.one * CircleSize;
if(IngameUI.PlanetViewEnabled || (!DebugUI.ShowAllPlanets && VisibilityStatus == PlanetVisibilityStatus.Hidden) || CircleSize == CircleSizeMin)
if(IngameUI.PlanetViewEnabled || (!DebugUI.ShowAllPlanets && VisibilityStatus == PlanetVisibilityStatus.Hidden) || CircleSize == CircleSizeMin || !Util.IsPointOnScreen(transform.position))
{ {
CircleTransform.gameObject.SetActive(false); CircleTransform.gameObject.SetActive(false);
} }


+ 1
- 1
Assets/GWConquest/Scripts/PlanetPlacement.cs View File

@ -252,7 +252,7 @@ namespace GWConquest
zone.zoneType = ZoneType.Ground; zone.zoneType = ZoneType.Ground;
nextZoneId++; nextZoneId++;
district.Planet = planet;
district.State.Planet = BoltEntityCache.Set(planet);
var otherDistricts = planet.GetComponentsInChildren<District>().ToList(); var otherDistricts = planet.GetComponentsInChildren<District>().ToList();


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


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


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

@ -2320,7 +2320,7 @@
"ReplicationMode": 1, "ReplicationMode": 1,
"Priority": 1, "Priority": 1,
"PropertyType": { "PropertyType": {
"$type": "Photon.Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
"$type": "Photon.Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
}, },
"AssetSettings": { "AssetSettings": {
"$type": "Photon.Bolt.Compiler.PropertyStateSettings, bolt.compiler", "$type": "Photon.Bolt.Compiler.PropertyStateSettings, bolt.compiler",


+ 2
- 2
Assets/Photon/PhotonBolt/resources/BoltRuntimeSettings.asset View File

@ -50,10 +50,10 @@ MonoBehaviour:
debugStartPort: 54321 debugStartPort: 54321
debugBuildMode: 1 debugBuildMode: 1
debugStartMapName: GalaxyMap debugStartMapName: GalaxyMap
debugPlayAsServer: 1
debugPlayAsServer: 0
showDebugInfo: 0 showDebugInfo: 0
overrideTimeScale: 1 overrideTimeScale: 1
debugEditorMode: 1
debugEditorMode: 2
consoleToggleKey: 9 consoleToggleKey: 9
consoleVisibleByDefault: 0 consoleVisibleByDefault: 0
compilationWarnLevel: 4 compilationWarnLevel: 4


Loading…
Cancel
Save