-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync building variations and road adjustments
- Loading branch information
Showing
7 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/basegame/Commands/Data/Buildings/BuildingSetVariationCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using CSM.API.Commands; | ||
using ProtoBuf; | ||
|
||
namespace CSM.BaseGame.Commands.Data.Buildings | ||
{ | ||
/// <summary> | ||
/// Called when the building variation was changed. | ||
/// </summary> | ||
/// Sent by: | ||
/// - BuildingHandler | ||
[ProtoContract] | ||
public class BuildingSetVariationCommand : CommandBase | ||
{ | ||
/// <summary> | ||
/// The id of the modified building. | ||
/// </summary> | ||
[ProtoMember(1)] | ||
public ushort Building { get; set; } | ||
|
||
/// <summary> | ||
/// The new variation flags. | ||
/// </summary> | ||
[ProtoMember(2)] | ||
public Building.Flags2 Variation { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Collections.Generic; | ||
using CSM.API.Commands; | ||
using ProtoBuf; | ||
|
||
namespace CSM.BaseGame.Commands.Data.Roads | ||
{ | ||
/// <summary> | ||
/// Sent when the player adjusts the extents of a road through the route menu. | ||
/// </summary> | ||
/// Sent by: RoadHandler | ||
[ProtoContract] | ||
public class RoadAdjustCommand : CommandBase | ||
{ | ||
/// <summary> | ||
/// The segments previously belonging to the edited road. | ||
/// </summary> | ||
[ProtoMember(1)] | ||
public HashSet<ushort> OriginalSegments { get; set; } | ||
|
||
/// <summary> | ||
/// The segments now belonging to the edited road. | ||
/// </summary> | ||
[ProtoMember(2)] | ||
public HashSet<ushort> IncludedSegments { get; set; } | ||
|
||
/// <summary> | ||
/// The selected road segment instance. | ||
/// </summary> | ||
[ProtoMember(3)] | ||
public InstanceID LastInstance { get; set; } | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/basegame/Commands/Handler/Buildings/BuildingSetVariationHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using ColossalFramework; | ||
using CSM.API.Commands; | ||
using CSM.API.Helpers; | ||
using CSM.BaseGame.Commands.Data.Buildings; | ||
|
||
namespace CSM.BaseGame.Commands.Handler.Buildings | ||
{ | ||
public class BuildingSetVariationHandler : CommandHandler<BuildingSetVariationCommand> | ||
{ | ||
protected override void Handle(BuildingSetVariationCommand command) | ||
{ | ||
IgnoreHelper.Instance.StartIgnore(); | ||
|
||
CommonBuildingAI building_ai = Singleton<BuildingManager>.instance.m_buildings.m_buffer[command.Building].Info.m_buildingAI as CommonBuildingAI; | ||
if (building_ai != null) | ||
building_ai.ReplaceVariation(command.Building, command.Variation); | ||
|
||
IgnoreHelper.Instance.EndIgnore(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Collections.Generic; | ||
using CSM.API.Commands; | ||
using CSM.API.Helpers; | ||
using CSM.BaseGame.Commands.Data.Roads; | ||
|
||
namespace CSM.BaseGame.Commands.Handler.Roads | ||
{ | ||
public class RoadAdjustHandler : CommandHandler<RoadAdjustCommand> | ||
{ | ||
private NetAdjust _adjustDummy; | ||
|
||
protected override void Handle(RoadAdjustCommand command) | ||
{ | ||
IgnoreHelper.Instance.StartIgnore(); | ||
|
||
if (_adjustDummy == null) | ||
{ | ||
SetupAdjustDummy(); | ||
} | ||
|
||
ReflectionHelper.SetAttr(_adjustDummy, "m_originalSegments", command.OriginalSegments); | ||
ReflectionHelper.SetAttr(_adjustDummy, "m_includedSegments", command.IncludedSegments); | ||
ReflectionHelper.SetAttr(_adjustDummy, "m_lastInstance", command.LastInstance); | ||
ReflectionHelper.SetAttr(_adjustDummy, "m_tempAdjustmentIndex", 0); | ||
|
||
_adjustDummy.ApplyModification(0); | ||
|
||
IgnoreHelper.Instance.EndIgnore(); | ||
} | ||
|
||
private void SetupAdjustDummy() | ||
{ | ||
_adjustDummy = new NetAdjust(); | ||
ReflectionHelper.SetAttr(_adjustDummy, "m_pathVisible", true); | ||
ReflectionHelper.SetAttr(_adjustDummy, "m_startPath", new FastList<ushort>()); | ||
ReflectionHelper.SetAttr(_adjustDummy, "m_endPath", new FastList<ushort>()); | ||
ReflectionHelper.SetAttr(_adjustDummy, "m_tempPath", new FastList<ushort>()); | ||
ReflectionHelper.SetAttr(_adjustDummy, "m_segmentQueue", new FastList<ushort>()); | ||
ReflectionHelper.SetAttr(_adjustDummy, "m_segmentData", new Dictionary<ushort, NetAdjust.SegmentData>()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters