mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-27 01:48:06 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f540025b0 | ||
|
|
d52ef620a7 | ||
|
|
07039886ae | ||
|
|
401185a2cc | ||
|
|
9439c01107 | ||
|
|
bc7a68b979 | ||
|
|
2d0af700a2 | ||
|
|
373810692d | ||
|
|
ff13300bcd | ||
|
|
6590e58f0a | ||
|
|
b2517803b2 | ||
|
|
46efff5a02 | ||
|
|
941f1924ec | ||
|
|
0310a412f1 | ||
|
|
2ec6399303 | ||
|
|
1a1c177969 | ||
|
|
a2254ea709 | ||
|
|
c237ce7f0a | ||
|
|
b9445499e2 | ||
|
|
3350680b5c | ||
|
|
ee2d8bef6e | ||
|
|
d7ea45b595 | ||
|
|
22f24f499c | ||
|
|
23c1921c2c | ||
|
|
0ba0a01908 | ||
|
|
7acf5061e3 |
No files matched your search
@@ -962,7 +962,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 160, y: 160}
|
||||
m_AnchoredPosition: {x: 180, y: 160}
|
||||
m_SizeDelta: {x: 160, y: 160}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!222 &1806521128227818516
|
||||
@@ -1016,7 +1016,28 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_MovementRange: 90
|
||||
m_DynamicOriginRange: 100
|
||||
m_ControlPath: <Joystick>/stick
|
||||
m_Behaviour: 0
|
||||
m_UseIsolatedInputActions: 0
|
||||
m_PointerDownAction:
|
||||
m_Name:
|
||||
m_Type: 0
|
||||
m_ExpectedControlType:
|
||||
m_Id:
|
||||
m_Processors:
|
||||
m_Interactions:
|
||||
m_SingletonActionBindings: []
|
||||
m_Flags: 0
|
||||
m_PointerMoveAction:
|
||||
m_Name:
|
||||
m_Type: 0
|
||||
m_ExpectedControlType:
|
||||
m_Id:
|
||||
m_Processors:
|
||||
m_Interactions:
|
||||
m_SingletonActionBindings: []
|
||||
m_Flags: 0
|
||||
--- !u!1 &1497448014832900950
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -42,9 +42,9 @@ namespace Core.DataReader.Scn
|
||||
[System.Serializable]
|
||||
public enum ScnSceneType
|
||||
{
|
||||
StoryA = 0, // 情节关城市村镇
|
||||
StoryB, // 情节关建筑内部
|
||||
Maze, // 战斗(迷宫)场景
|
||||
OutDoor = 0, // 情节关城市村镇
|
||||
InDoor, // 情节关建筑内部
|
||||
Maze, // 迷宫场景
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
@@ -53,72 +53,73 @@ namespace Core.DataReader.Scn
|
||||
AutoTrigger = 0, // 自动触发点
|
||||
Shakeable = 1, // 碰到后摇晃的物品
|
||||
#if PAL3
|
||||
Collidable = 2, // 碰到后翻倒的物品
|
||||
Collidable = 2, // 碰到后翻倒的物品(仙三独有)
|
||||
#elif PAL3A
|
||||
Switch = 2, // 开关
|
||||
WuLingSwitch = 2, // 五灵开关 (可触发其他机关,外传独有)
|
||||
#endif
|
||||
Arrow = 3, // 飞箭类 (霹雳堂总舵飞剑)
|
||||
FallableWeapon = 4, // 落下的伤害物体 (冰棱)
|
||||
MovableCarrier = 5, // 移动浮板 (固定速度和路线往复移动,可载人)
|
||||
Trap = 6, // 陷阱 (调用脚本切换场景)
|
||||
RotatingBridge = 7, // 旋传石梁 (一字型)
|
||||
RotatingWall = 8, // 旋转墙 (折尺型)
|
||||
RotatingBridge = 7, // 旋传石梁 (仙三独有)
|
||||
Teapot = 8, // 茶壶 (外传独有)
|
||||
PreciseTrigger = 9, // 精确触发点
|
||||
WindBlower = 10, // 风口
|
||||
Pushable = 11, // 推箱子
|
||||
SpecialSwitch = 12, // 主角特技机关
|
||||
Impulsive = 13, // 冲撞类机关
|
||||
Pushable = 11, // 推箱子(仙三独有)
|
||||
SpecialSwitch = 12, // 主角特技机关(仙三独有)
|
||||
Impulsive = 13, // 冲撞类机关(仙三独有)
|
||||
Door = 14, // 门,场景切换点
|
||||
Climbable = 15, // 藤蔓或梯子 (可爬物)
|
||||
InvestigationTrigger = 16, // 调查触发物体
|
||||
StaticOrAnimated = 17, // 死物体或者随机动画播放(通用参数[0]:对应的地面是否可通过)
|
||||
Billboard = 18, // 公告板
|
||||
SuspensionBridge = 19, // 吊桥 (壁山)
|
||||
SuspensionBridge = 19, // 吊桥 (仙三独有)
|
||||
VirtualInvestigationTrigger = 20, // 虚拟BOX调查触发
|
||||
EyeBall = 21, // 锁妖塔:眼球
|
||||
EyeBall = 21, // 锁妖塔:眼球(仙三独有)
|
||||
LiftingPlatform = 22, // 锁妖塔:升降铁链或平台
|
||||
// 通用参数[0]:为升起后的高度,需要用其他开关间接触发
|
||||
// 通用参数[1]:升起后到高层
|
||||
// 通用参数[2]:平台上的其他物件编号
|
||||
// 通用参数[3]:初始为可通过?)
|
||||
#if PAL3
|
||||
Switch = 23, // 开关 (可触发其他机关)
|
||||
#elif PAL3A
|
||||
NotUsed = 23, // 弃用
|
||||
#endif
|
||||
Switch = 23, // 普通开关 (可触发其他机关,仙三独有)
|
||||
Collectable = 24, // 可以拣起的道具 (通用参数[0]:得到物品的数据库ID)
|
||||
General = 25, // 普通物品
|
||||
RareChest = 26, // 迷宫大宝箱
|
||||
WishPool = 27, // 许愿池
|
||||
#if PAL3
|
||||
WishPool = 27, // 许愿池(仙三独有)
|
||||
#elif PAL3A
|
||||
ToggleSwitch = 27, // 普通开关的变种(可触发其他机关,外传独有)
|
||||
#endif
|
||||
ColdWeapon = 28, // (M24)剑或锤
|
||||
GravitySwitch = 29, // 重力机关(乌龟)
|
||||
ElevatorDoor = 30, // 升降机关门
|
||||
WaterSurface = 31, // 水面机关
|
||||
GravitySwitch = 29, // 重力机关(乌龟,仙三独有)
|
||||
ElevatorDoor = 30, // 升降机关门(仙三独有)
|
||||
WaterSurfaceRoadBlocker = 31, // 水面机关/路障(仙三独有)
|
||||
PiranhaFlower = 32, // 食人花
|
||||
PedalSwitch = 33, // 踏板开关
|
||||
SwordBridge = 34, // (m24)剑桥(触发后向前伸)
|
||||
SwordBridge = 34, // 剑桥(触发后向前伸,仙三独有)
|
||||
SlideWay = 35, // 滑道
|
||||
FallableObstacle = 36, // 坠落的障碍物
|
||||
DivineTreeFlower = 37, // (神树)花
|
||||
DivineTreePortal = 38, // (神树)传送点
|
||||
Elevator = 39, // (神魔之井)电梯
|
||||
ElevatorPedal = 40, // 上下传送板
|
||||
FallableObstacle = 36, // 坠落的障碍物(仙三独有)
|
||||
DivineTreeFlower = 37, // 神树花(仙三独有)
|
||||
DivineTreePortal = 38, // 神树传送点
|
||||
Elevator = 39, // 神魔之井电梯(仙三独有)
|
||||
ElevatorPedal = 40, // 上下传送板(仙三独有)
|
||||
Chest = 41, // 小宝箱
|
||||
SavingPoint = 42, // 存盘点
|
||||
SceneSfx = 43, // 场景音效
|
||||
JumpableArea = 44, // 可跳跃区域
|
||||
|
||||
// PAL3A new scene objects
|
||||
UnknownObj47 = 47, // PAL3A m19 8
|
||||
UnknownObj48 = 48, // PAL3A m19 8
|
||||
UnknownObj49 = 49, // PAL3A m05 3, m06 2, m17 2, m17 3, m17 4, m18 1, m18 2
|
||||
UnknownObj51 = 51, // PAL3A m10 2
|
||||
UnknownObj52 = 52, // PAL3A m01 1
|
||||
UnknownObj53 = 53, // PAL3A m17 1, m17 2, m17 3, m17 4
|
||||
UnknownObj54 = 54, // PAL3A m13 1, m13 2, m13 3, m13 4
|
||||
UnknownObj55 = 55, // PAL3A m13 1, m13 2, m13 3, m13 4
|
||||
UnknownObj56 = 56, // PAL3A m15 1
|
||||
UnknownObj59 = 59, // PAL3A m15 2
|
||||
// 以下所有均为仙三外传中新增的场景物件类型
|
||||
PaperweightDesk = 47, // 镇尺桌
|
||||
Paperweight = 48, // 镇尺
|
||||
RoadElevatorOrBlocker = 49, // 可升降路面或者是阻挡物
|
||||
RetractableBlocker = 51, // 可收回路障
|
||||
RotatingWall = 52, // T形旋转石门
|
||||
WaterSurface = 53, // 升降水面
|
||||
ThreePhaseBridge = 54, // 三相桥
|
||||
ThreePhaseSwitch = 55, // 三相开关
|
||||
MushroomBridge = 56, // 蘑菇桥
|
||||
SectorBridge = 59, // 扇型桥
|
||||
}
|
||||
|
||||
// SCN (.scn) file header
|
||||
@@ -308,7 +309,7 @@ namespace Core.DataReader.Scn
|
||||
// 在哪个地层
|
||||
public byte LayerIndex;
|
||||
|
||||
// 五灵属性,0~5代表,用于大宝箱
|
||||
// 五灵属性,0~5代表,用于大宝箱和三外中具有五灵属性的机关
|
||||
public byte WuLing;
|
||||
|
||||
/*
|
||||
@@ -332,7 +333,7 @@ namespace Core.DataReader.Scn
|
||||
public int[] Parameters;
|
||||
|
||||
#if PAL3A
|
||||
public uint Unknown1; // always 0
|
||||
public uint NotUsed; // always 0
|
||||
#endif
|
||||
|
||||
// 触发条件
|
||||
@@ -345,7 +346,7 @@ namespace Core.DataReader.Scn
|
||||
public string FailedMessage; // char[16] 失败提示字符串名称
|
||||
|
||||
#if PAL3A
|
||||
public uint Unknown2;
|
||||
public uint Unknown; // TODO
|
||||
#endif
|
||||
|
||||
public uint ScriptId;
|
||||
@@ -360,9 +361,9 @@ namespace Core.DataReader.Scn
|
||||
public byte DependentObjectId;
|
||||
|
||||
public Bounds Bounds;
|
||||
public float GameBoxXRotation; // 绕X轴旋转
|
||||
public float GameBoxXRotation; // 绕X轴旋转
|
||||
#if PAL3A
|
||||
public float GameBoxZRotation; // 绕Z轴旋转
|
||||
public float GameBoxZRotation; // 绕Z轴旋转
|
||||
#endif
|
||||
public string SfxName; // 音效文件名
|
||||
|
||||
@@ -372,7 +373,7 @@ namespace Core.DataReader.Scn
|
||||
public uint ScriptMoved;
|
||||
|
||||
#if PAL3A
|
||||
public uint Unknown3;
|
||||
public uint CanOnlyBeTriggeredOnce;
|
||||
#endif
|
||||
|
||||
public uint[] Reserved; // PAL3: 52 DWORDs PAL3A: 44 DWORDs
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace Core.DataReader.Scn
|
||||
#endif
|
||||
|
||||
#if PAL3A
|
||||
var unknown1 = reader.ReadUInt32(); // TODO
|
||||
var notUsed = reader.ReadUInt32();
|
||||
#endif
|
||||
|
||||
var requireSpecialAction = reader.ReadByte();
|
||||
@@ -145,7 +145,7 @@ namespace Core.DataReader.Scn
|
||||
_ = reader.ReadByte(); // Empty padding byte to complete 4-byte alignment
|
||||
|
||||
#if PAL3A
|
||||
var unknown2 = reader.ReadUInt32(); // TODO
|
||||
var unknown = reader.ReadUInt32(); // TODO
|
||||
#endif
|
||||
|
||||
var scriptId = reader.ReadUInt32();
|
||||
@@ -180,7 +180,7 @@ namespace Core.DataReader.Scn
|
||||
var scriptMoved = reader.ReadUInt32();
|
||||
|
||||
#if PAL3A
|
||||
var unknown3 = reader.ReadUInt32(); // TODO
|
||||
var canOnlyBeTriggeredOnce = reader.ReadUInt32();
|
||||
#endif
|
||||
|
||||
#if PAL3
|
||||
@@ -213,7 +213,7 @@ namespace Core.DataReader.Scn
|
||||
Parameters = parameters,
|
||||
|
||||
#if PAL3A
|
||||
Unknown1 = unknown1, // TODO
|
||||
NotUsed = notUsed,
|
||||
#endif
|
||||
|
||||
RequireSpecialAction = requireSpecialAction,
|
||||
@@ -226,7 +226,7 @@ namespace Core.DataReader.Scn
|
||||
FailedMessage = failedMessage,
|
||||
|
||||
#if PAL3A
|
||||
Unknown2 = unknown2, // TODO
|
||||
Unknown = unknown, // TODO
|
||||
#endif
|
||||
|
||||
ScriptId = scriptId,
|
||||
@@ -252,7 +252,7 @@ namespace Core.DataReader.Scn
|
||||
ScriptMoved = scriptMoved,
|
||||
|
||||
#if PAL3A
|
||||
Unknown3 = unknown3, // TODO
|
||||
CanOnlyBeTriggeredOnce = canOnlyBeTriggeredOnce,
|
||||
#endif
|
||||
|
||||
Reserved = reserved,
|
||||
|
||||
@@ -46,6 +46,11 @@ namespace Core.GameBox
|
||||
public int Top;
|
||||
public int Right;
|
||||
public int Bottom;
|
||||
|
||||
public bool IsEmpty => Left == 0 &&
|
||||
Top == 0 &&
|
||||
Right == 0 &&
|
||||
Bottom == 0;
|
||||
}
|
||||
|
||||
public static class GameBoxVertexType
|
||||
|
||||
@@ -165,6 +165,12 @@ namespace Core.Utils
|
||||
return collider.ClosestPoint(point) == point;
|
||||
}
|
||||
|
||||
public static bool IsPointWithinCollider(Collider collider, Vector3 point, float tolerance)
|
||||
{
|
||||
if (collider == null) return false;
|
||||
return Vector3.Distance(collider.ClosestPoint(point), point) < tolerance;
|
||||
}
|
||||
|
||||
public static Vector3[] CalculateNormals(Vector3[] vertices, int[] triangles)
|
||||
{
|
||||
Vector3[] normals = new Vector3[vertices.Length];
|
||||
|
||||
@@ -597,9 +597,13 @@ namespace Pal3.Actor
|
||||
{
|
||||
var targetYPosition = platformInfo.Platform.GetPlatformHeight();
|
||||
|
||||
// Tolerance is used to allow the actor to be able to walk
|
||||
// on a standing platform that has a slight slope
|
||||
const float tolerance = 0.3f;
|
||||
|
||||
// Make sure actor is on top of the platform
|
||||
if (Utility.IsPointWithinCollider(platformInfo.Platform.GetCollider(),
|
||||
new Vector3(newPosition.x, targetYPosition, newPosition.z)) &&
|
||||
new Vector3(newPosition.x, targetYPosition, newPosition.z), tolerance) &&
|
||||
Mathf.Abs(currentPosition.y - targetYPosition) <= MAX_Y_DIFFERENTIAL_CROSS_PLATFORM)
|
||||
{
|
||||
newYPosition = targetYPosition;
|
||||
|
||||
@@ -36,6 +36,8 @@ namespace Pal3.Camera
|
||||
#if PAL3A
|
||||
ICommandExecutor<CameraOrbitHorizontalCommand>,
|
||||
ICommandExecutor<CameraOrbitVerticalCommand>,
|
||||
ICommandExecutor<CameraMoveToLookAtPointCommand>,
|
||||
ICommandExecutor<CameraMoveToDefaultLookAtPointCommand>,
|
||||
#endif
|
||||
ICommandExecutor<CameraFadeInCommand>,
|
||||
ICommandExecutor<CameraFadeInWhiteCommand>,
|
||||
@@ -43,7 +45,7 @@ namespace Pal3.Camera
|
||||
ICommandExecutor<CameraFadeOutWhiteCommand>,
|
||||
ICommandExecutor<CameraPushCommand>,
|
||||
ICommandExecutor<CameraMoveCommand>,
|
||||
ICommandExecutor<CameraFreeCommand>,
|
||||
ICommandExecutor<CameraFollowPlayerCommand>,
|
||||
ICommandExecutor<CameraSetYawCommand>,
|
||||
ICommandExecutor<CameraFocusOnActorCommand>,
|
||||
ICommandExecutor<CameraFocusOnSceneObjectCommand>,
|
||||
@@ -53,9 +55,9 @@ namespace Pal3.Camera
|
||||
ICommandExecutor<ResetGameStateCommand>
|
||||
{
|
||||
private const float FADE_ANIMATION_DURATION = 3f;
|
||||
private const float SCENE_STORY_B_ROOM_FLOOR_HEIGHT = 1.6f;
|
||||
private const float SCENE_IN_DOOR_ROOM_FLOOR_HEIGHT = 1.6f;
|
||||
private const float CAMERA_DEFAULT_DISTANCE = 46f;
|
||||
private const float CAMERA_SCENE_STORY_B_DISTANCE = 34f;
|
||||
private const float CAMERA_IN_DOOR_DISTANCE = 34f;
|
||||
private const float CAMERA_ROTATION_SPEED_KEY_PRESS = 120f;
|
||||
private const float CAMERA_ROTATION_SPEED_SCROLL = 15f;
|
||||
private const float CAMERA_ROTATION_SPEED_DRAG = 10f;
|
||||
@@ -64,28 +66,24 @@ namespace Pal3.Camera
|
||||
|
||||
private Camera _camera;
|
||||
private Image _curtainImage;
|
||||
|
||||
private GameObject _lookAtGameObject;
|
||||
private Vector3 _lastLookAtPoint = Vector3.zero;
|
||||
private Vector3 _cameraMoveVelocity = Vector3.zero;
|
||||
|
||||
private bool _shouldResetVelocity = false;
|
||||
|
||||
private Vector3 _actualPosition = Vector3.zero;
|
||||
private Vector3 _actualLookAtPoint = Vector3.zero;
|
||||
|
||||
private Vector3 _cameraOffset = Vector3.zero;
|
||||
private float _lookAtPointYOffset;
|
||||
|
||||
private bool _free = true;
|
||||
private bool _freeToRotate;
|
||||
private bool _cameraFollowPlayer = true;
|
||||
private bool _shouldResetVelocity = false;
|
||||
private int _currentAppliedDefaultTransformOption = 0;
|
||||
|
||||
private PlayerInputActions _inputActions;
|
||||
private PlayerGamePlayController _gamePlayController;
|
||||
private SceneManager _sceneManager;
|
||||
private GameStateManager _gameStateManager;
|
||||
private bool _freeToRotate;
|
||||
|
||||
private GameObject _lookAtGameObject;
|
||||
|
||||
private int _currentAppliedDefaultTransformOption = 0;
|
||||
|
||||
private RectTransform _joyStickRect;
|
||||
private float _joyStickMovementRange;
|
||||
@@ -138,7 +136,7 @@ namespace Pal3.Camera
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (!_free)
|
||||
if (!_cameraFollowPlayer)
|
||||
{
|
||||
_shouldResetVelocity = true;
|
||||
return;
|
||||
@@ -270,12 +268,11 @@ namespace Pal3.Camera
|
||||
|
||||
private IEnumerator MoveAsync(Vector3 position,
|
||||
float duration,
|
||||
int mode,
|
||||
AnimationCurveType curveType,
|
||||
WaitUntilCanceled waiter = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
_cameraAnimationInProgress = true;
|
||||
var curveType = (AnimationCurveType) mode;
|
||||
Transform cameraTransform = _camera.transform;
|
||||
Vector3 oldPosition = cameraTransform.position;
|
||||
yield return AnimationHelper.MoveTransformAsync(cameraTransform, position, duration, curveType, cancellationToken);
|
||||
@@ -390,22 +387,19 @@ namespace Pal3.Camera
|
||||
{
|
||||
switch (sceneInfo.SceneType)
|
||||
{
|
||||
case ScnSceneType.StoryB:
|
||||
_freeToRotate = false;
|
||||
_lookAtPointYOffset = SCENE_STORY_B_ROOM_FLOOR_HEIGHT;
|
||||
_camera.nearClipPlane = 1f;
|
||||
_camera.farClipPlane = 500f;
|
||||
ApplyDefaultSettings(1);
|
||||
break;
|
||||
case ScnSceneType.StoryA:
|
||||
_freeToRotate = true;
|
||||
case ScnSceneType.OutDoor:
|
||||
_lookAtPointYOffset = 0;
|
||||
_camera.nearClipPlane = 2f;
|
||||
_camera.farClipPlane = 800f;
|
||||
ApplyDefaultSettings(0);
|
||||
break;
|
||||
case ScnSceneType.InDoor:
|
||||
_lookAtPointYOffset = SCENE_IN_DOOR_ROOM_FLOOR_HEIGHT;
|
||||
_camera.nearClipPlane = 1f;
|
||||
_camera.farClipPlane = 500f;
|
||||
ApplyDefaultSettings(1);
|
||||
break;
|
||||
case ScnSceneType.Maze:
|
||||
_freeToRotate = true;
|
||||
_lookAtPointYOffset = 0;
|
||||
_camera.nearClipPlane = 2f;
|
||||
_camera.farClipPlane = 800f;
|
||||
@@ -431,23 +425,27 @@ namespace Pal3.Camera
|
||||
switch (option)
|
||||
{
|
||||
case 0:
|
||||
_freeToRotate = true;
|
||||
cameraFov = HorizontalToVerticalFov(26.0f, 4f/3f);
|
||||
cameraDistance = CAMERA_DEFAULT_DISTANCE;
|
||||
cameraRotation = GameBoxInterpreter.ToUnityRotation(-30.37f, -52.65f, 0f);
|
||||
break;
|
||||
case 1:
|
||||
_freeToRotate = false;
|
||||
cameraFov = HorizontalToVerticalFov(24.05f, 4f/3f);
|
||||
cameraDistance = CAMERA_SCENE_STORY_B_DISTANCE;
|
||||
cameraDistance = CAMERA_IN_DOOR_DISTANCE;
|
||||
cameraRotation = GameBoxInterpreter.ToUnityRotation(-19.48f, 33.24f, 0f);
|
||||
break;
|
||||
case 2:
|
||||
_freeToRotate = false;
|
||||
cameraFov = HorizontalToVerticalFov(24.05f, 4f/3f);
|
||||
cameraDistance = CAMERA_SCENE_STORY_B_DISTANCE;
|
||||
cameraDistance = CAMERA_IN_DOOR_DISTANCE;
|
||||
cameraRotation = GameBoxInterpreter.ToUnityRotation(-19.48f, -33.24f, 0f);
|
||||
break;
|
||||
case 3:
|
||||
_freeToRotate = false;
|
||||
cameraFov = HorizontalToVerticalFov(24.05f, 4f/3f);
|
||||
cameraDistance = CAMERA_SCENE_STORY_B_DISTANCE;
|
||||
cameraDistance = CAMERA_IN_DOOR_DISTANCE;
|
||||
cameraRotation = GameBoxInterpreter.ToUnityRotation(-19.48f, 0f, 0f);
|
||||
break;
|
||||
default:
|
||||
@@ -479,7 +477,7 @@ namespace Pal3.Camera
|
||||
|
||||
ApplyDefaultSettings(command.Option);
|
||||
_currentAppliedDefaultTransformOption = command.Option;
|
||||
_free = true;
|
||||
_cameraFollowPlayer = true;
|
||||
}
|
||||
|
||||
public void Execute(CameraSetTransformCommand command)
|
||||
@@ -502,16 +500,16 @@ namespace Pal3.Camera
|
||||
|
||||
if (_gameStateManager.GetCurrentState() != GameState.Gameplay)
|
||||
{
|
||||
_free = false;
|
||||
_cameraFollowPlayer = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(CameraFreeCommand command)
|
||||
public void Execute(CameraFollowPlayerCommand command)
|
||||
{
|
||||
if (!_asyncCameraAnimationCts.IsCancellationRequested) _asyncCameraAnimationCts.Cancel();
|
||||
|
||||
_lookAtGameObject = null;
|
||||
_free = command.Free == 1;
|
||||
_cameraFollowPlayer = command.Follow == 1;
|
||||
}
|
||||
|
||||
public void Execute(CameraShakeEffectCommand command)
|
||||
@@ -562,66 +560,6 @@ namespace Pal3.Camera
|
||||
#endif
|
||||
}
|
||||
|
||||
#if PAL3A
|
||||
public void Execute(CameraOrbitHorizontalCommand command)
|
||||
{
|
||||
if (!_asyncCameraAnimationCts.IsCancellationRequested) _asyncCameraAnimationCts.Cancel();
|
||||
|
||||
var oldDistance = _cameraOffset.magnitude;
|
||||
var newDistance = GameBoxInterpreter.ToUnityDistance(command.GameBoxDistance);
|
||||
var distanceDelta = newDistance - oldDistance;
|
||||
|
||||
if (command.Synchronous == 1)
|
||||
{
|
||||
var waiter = new WaitUntilCanceled();
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
|
||||
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
StartCoroutine(OrbitAsync(rotation, command.Duration, (AnimationCurveType)command.CurveType, distanceDelta, waiter));
|
||||
}
|
||||
else
|
||||
{
|
||||
_asyncCameraAnimationCts = new CancellationTokenSource();
|
||||
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
StartCoroutine(OrbitAsync(rotation,
|
||||
command.Duration,
|
||||
(AnimationCurveType)command.CurveType,
|
||||
distanceDelta,
|
||||
waiter: null,
|
||||
_asyncCameraAnimationCts.Token));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if PAL3A
|
||||
public void Execute(CameraOrbitVerticalCommand command)
|
||||
{
|
||||
if (!_asyncCameraAnimationCts.IsCancellationRequested) _asyncCameraAnimationCts.Cancel();
|
||||
|
||||
var oldDistance = _cameraOffset.magnitude;
|
||||
var newDistance = GameBoxInterpreter.ToUnityDistance(command.GameBoxDistance);
|
||||
var distanceDelta = newDistance - oldDistance;
|
||||
|
||||
if (command.Synchronous == 1)
|
||||
{
|
||||
var waiter = new WaitUntilCanceled();
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
|
||||
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
StartCoroutine(OrbitAsync(rotation, command.Duration, (AnimationCurveType)command.CurveType, distanceDelta, waiter));
|
||||
}
|
||||
else
|
||||
{
|
||||
_asyncCameraAnimationCts = new CancellationTokenSource();
|
||||
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
StartCoroutine(OrbitAsync(rotation,
|
||||
command.Duration,
|
||||
(AnimationCurveType)command.CurveType,
|
||||
distanceDelta,
|
||||
waiter: null,
|
||||
_asyncCameraAnimationCts.Token));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public void Execute(CameraFadeInCommand command)
|
||||
{
|
||||
if (!_cameraFadeAnimationCts.IsCancellationRequested) _cameraFadeAnimationCts.Cancel();
|
||||
@@ -703,7 +641,7 @@ namespace Pal3.Camera
|
||||
command.GameBoxXPosition,
|
||||
command.GameBoxYPosition,
|
||||
command.GameBoxZPosition));
|
||||
StartCoroutine(MoveAsync(position, command.Duration, command.Mode, waiter));
|
||||
StartCoroutine(MoveAsync(position, command.Duration, (AnimationCurveType)command.CurveType, waiter));
|
||||
}
|
||||
#if PAL3A
|
||||
else
|
||||
@@ -715,7 +653,7 @@ namespace Pal3.Camera
|
||||
command.GameBoxZPosition));
|
||||
StartCoroutine(MoveAsync(position,
|
||||
command.Duration,
|
||||
command.Mode,
|
||||
(AnimationCurveType)command.CurveType,
|
||||
waiter: null,
|
||||
_asyncCameraAnimationCts.Token));
|
||||
}
|
||||
@@ -733,7 +671,7 @@ namespace Pal3.Camera
|
||||
if (_sceneManager.GetCurrentScene() is not { } currentScene) return;
|
||||
|
||||
// Remember the current scene's camera position and rotation
|
||||
if (_free && currentScene.GetSceneInfo().SceneType != ScnSceneType.StoryB)
|
||||
if (_cameraFollowPlayer && currentScene.GetSceneInfo().SceneType != ScnSceneType.InDoor)
|
||||
{
|
||||
var cameraTransform = _camera.transform;
|
||||
_cameraLastKnownSceneState.Add((
|
||||
@@ -755,7 +693,7 @@ namespace Pal3.Camera
|
||||
ApplySceneSettings(notification.NewSceneInfo);
|
||||
|
||||
// Apply the last known scene state if found in record.
|
||||
if (_free && notification.NewSceneInfo.SceneType != ScnSceneType.StoryB)
|
||||
if (_cameraFollowPlayer && notification.NewSceneInfo.SceneType != ScnSceneType.InDoor)
|
||||
{
|
||||
if (_cameraLastKnownSceneState.Count > 0 && _cameraLastKnownSceneState.Any(_ =>
|
||||
_.sceneInfo.ModelEquals(notification.NewSceneInfo)))
|
||||
@@ -786,13 +724,124 @@ namespace Pal3.Camera
|
||||
|
||||
public void Execute(GameStateChangedNotification command)
|
||||
{
|
||||
if (command.NewState == GameState.Gameplay) _free = true;
|
||||
if (command.NewState == GameState.Gameplay)
|
||||
{
|
||||
_cameraFollowPlayer = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(ResetGameStateCommand command)
|
||||
{
|
||||
_cameraLastKnownSceneState.Clear();
|
||||
_free = true;
|
||||
_cameraFollowPlayer = true;
|
||||
}
|
||||
|
||||
#if PAL3A
|
||||
public void Execute(CameraOrbitHorizontalCommand command)
|
||||
{
|
||||
if (!_asyncCameraAnimationCts.IsCancellationRequested) _asyncCameraAnimationCts.Cancel();
|
||||
|
||||
var oldDistance = _cameraOffset.magnitude;
|
||||
var newDistance = GameBoxInterpreter.ToUnityDistance(command.GameBoxDistance);
|
||||
var distanceDelta = newDistance - oldDistance;
|
||||
|
||||
if (command.Synchronous == 1)
|
||||
{
|
||||
var waiter = new WaitUntilCanceled();
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
|
||||
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
StartCoroutine(OrbitAsync(rotation, command.Duration, (AnimationCurveType)command.CurveType, distanceDelta, waiter));
|
||||
}
|
||||
else
|
||||
{
|
||||
_asyncCameraAnimationCts = new CancellationTokenSource();
|
||||
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
StartCoroutine(OrbitAsync(rotation,
|
||||
command.Duration,
|
||||
(AnimationCurveType)command.CurveType,
|
||||
distanceDelta,
|
||||
waiter: null,
|
||||
_asyncCameraAnimationCts.Token));
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(CameraOrbitVerticalCommand command)
|
||||
{
|
||||
if (!_asyncCameraAnimationCts.IsCancellationRequested) _asyncCameraAnimationCts.Cancel();
|
||||
|
||||
var oldDistance = _cameraOffset.magnitude;
|
||||
var newDistance = GameBoxInterpreter.ToUnityDistance(command.GameBoxDistance);
|
||||
var distanceDelta = newDistance - oldDistance;
|
||||
|
||||
if (command.Synchronous == 1)
|
||||
{
|
||||
var waiter = new WaitUntilCanceled();
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
|
||||
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
StartCoroutine(OrbitAsync(rotation, command.Duration, (AnimationCurveType)command.CurveType, distanceDelta, waiter));
|
||||
}
|
||||
else
|
||||
{
|
||||
_asyncCameraAnimationCts = new CancellationTokenSource();
|
||||
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
StartCoroutine(OrbitAsync(rotation,
|
||||
command.Duration,
|
||||
(AnimationCurveType)command.CurveType,
|
||||
distanceDelta,
|
||||
waiter: null,
|
||||
_asyncCameraAnimationCts.Token));
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(CameraMoveToLookAtPointCommand command)
|
||||
{
|
||||
if (!_asyncCameraAnimationCts.IsCancellationRequested) _asyncCameraAnimationCts.Cancel();
|
||||
|
||||
_cameraFollowPlayer = false;
|
||||
const float duration = 1f;
|
||||
|
||||
if (command.Synchronous == 1)
|
||||
{
|
||||
var waiter = new WaitUntilCanceled();
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
|
||||
Vector3 position = _cameraOffset + GameBoxInterpreter.ToUnityPosition(new Vector3(
|
||||
command.GameBoxXPosition,
|
||||
command.GameBoxYPosition,
|
||||
command.GameBoxZPosition));
|
||||
StartCoroutine(MoveAsync(position, duration, AnimationCurveType.Sine, waiter));
|
||||
}
|
||||
else
|
||||
{
|
||||
_asyncCameraAnimationCts = new CancellationTokenSource();
|
||||
Vector3 position = _cameraOffset + GameBoxInterpreter.ToUnityPosition(new Vector3(
|
||||
command.GameBoxXPosition,
|
||||
command.GameBoxYPosition,
|
||||
command.GameBoxZPosition));
|
||||
StartCoroutine(MoveAsync(position,
|
||||
duration,
|
||||
AnimationCurveType.Sine,
|
||||
waiter: null,
|
||||
_asyncCameraAnimationCts.Token));
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(CameraMoveToDefaultLookAtPointCommand command)
|
||||
{
|
||||
if (!_asyncCameraAnimationCts.IsCancellationRequested) _asyncCameraAnimationCts.Cancel();
|
||||
|
||||
var waiter = new WaitUntilCanceled();
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
|
||||
|
||||
if (_gamePlayController.TryGetPlayerActorLastKnownPosition(out Vector3 playerActorPosition))
|
||||
{
|
||||
Vector3 position = _cameraOffset + playerActorPosition;
|
||||
StartCoroutine(MoveAsync(position, command.Duration, AnimationCurveType.Sine, waiter));
|
||||
}
|
||||
else
|
||||
{
|
||||
_cameraFollowPlayer = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
+2
@@ -5,6 +5,7 @@
|
||||
|
||||
namespace Pal3.Command.InternalCommands
|
||||
{
|
||||
#if PAL3
|
||||
[AvailableInConsole]
|
||||
public class SceneSaveGlobalBidirectionalPushableObjectStateCommand : ICommand
|
||||
{
|
||||
@@ -24,4 +25,5 @@ namespace Pal3.Command.InternalCommands
|
||||
public int ObjectId { get; }
|
||||
public int State { get; }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.Command.InternalCommands
|
||||
{
|
||||
#if PAL3A
|
||||
[AvailableInConsole]
|
||||
public class SceneSaveGlobalThreePhaseSwitchStateCommand : ICommand
|
||||
{
|
||||
public SceneSaveGlobalThreePhaseSwitchStateCommand(string cityName,
|
||||
string sceneName,
|
||||
int objectId,
|
||||
int previousState,
|
||||
int currentState)
|
||||
{
|
||||
CityName = cityName;
|
||||
SceneName = sceneName;
|
||||
ObjectId = objectId;
|
||||
PreviousState = previousState;
|
||||
CurrentState = currentState;
|
||||
}
|
||||
|
||||
public string CityName { get; }
|
||||
public string SceneName { get; }
|
||||
public int ObjectId { get; }
|
||||
public int PreviousState { get; }
|
||||
public int CurrentState { get; }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 521026f21abf431686ae2531379b06a0
|
||||
timeCreated: 1678617156
|
||||
@@ -16,7 +16,7 @@ namespace Pal3.Command.InternalCommands
|
||||
AudioSourceName = audioSourceName;
|
||||
DisposeSource = disposeSource;
|
||||
}
|
||||
|
||||
|
||||
[JsonIgnore] public GameObject Parent { get; }
|
||||
public string AudioSourceName { get; }
|
||||
public bool DisposeSource { get; }
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.Command.InternalCommands
|
||||
{
|
||||
#if PAL3A
|
||||
public class ThreePhaseSwitchStateChangedNotification : ICommand
|
||||
{
|
||||
public ThreePhaseSwitchStateChangedNotification(
|
||||
int objectId,
|
||||
int previousState,
|
||||
int currentState)
|
||||
{
|
||||
ObjectId = objectId;
|
||||
PreviousState = previousState;
|
||||
CurrentState = currentState;
|
||||
}
|
||||
|
||||
public int ObjectId { get; }
|
||||
public int PreviousState { get; }
|
||||
public int CurrentState { get; }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4d89e390cf741deb714c97264b977b8
|
||||
timeCreated: 1678673973
|
||||
@@ -336,19 +336,35 @@ namespace Pal3.Command
|
||||
}
|
||||
|
||||
// <auto-generated/>
|
||||
[ConsoleMethodAttribute("CameraFree", "取消镜头锁定")]
|
||||
public static void CameraFree(System.Int32 free)
|
||||
[ConsoleMethodAttribute("CameraFollowPlayer", "镜头是否锁定并跟随在主角身上,参数:1锁定并跟随,0解锁")]
|
||||
public static void CameraFollowPlayer(System.Int32 follow)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new CameraFreeCommand(free));
|
||||
new CameraFollowPlayerCommand(follow));
|
||||
}
|
||||
|
||||
// <auto-generated/>
|
||||
[ConsoleMethodAttribute("CameraMove", "镜头当前位置移动(保持当前角度),参数:原GameBox引擎下的一个三维坐标(X,Y,Z),动作时间,插值类型,同步(1暂停当前脚本运行,0异步进行动画且继续执行脚本)")]
|
||||
public static void CameraMove(System.Single gameBoxXPosition, System.Single gameBoxYPosition, System.Single gameBoxZPosition, System.Single duration, System.Int32 mode, System.Int32 synchronous)
|
||||
public static void CameraMove(System.Single gameBoxXPosition, System.Single gameBoxYPosition, System.Single gameBoxZPosition, System.Single duration, System.Int32 curveType, System.Int32 synchronous)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new CameraMoveCommand(gameBoxXPosition, gameBoxYPosition, gameBoxZPosition, duration, mode, synchronous));
|
||||
new CameraMoveCommand(gameBoxXPosition, gameBoxYPosition, gameBoxZPosition, duration, curveType, synchronous));
|
||||
}
|
||||
|
||||
// <auto-generated/>
|
||||
[ConsoleMethodAttribute("CameraMoveToDefaultLookAtPoint", "相机移动至默认焦距点(主角)")]
|
||||
public static void CameraMoveToDefaultLookAtPoint(System.Int32 duration)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new CameraMoveToDefaultLookAtPointCommand(duration));
|
||||
}
|
||||
|
||||
// <auto-generated/>
|
||||
[ConsoleMethodAttribute("CameraMoveToLookAtPoint", "移动相机并看向固定点")]
|
||||
public static void CameraMoveToLookAtPoint(System.Single gameBoxXPosition, System.Single gameBoxYPosition, System.Single gameBoxZPosition, System.Int32 synchronous)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new CameraMoveToLookAtPointCommand(gameBoxXPosition, gameBoxYPosition, gameBoxZPosition, synchronous));
|
||||
}
|
||||
|
||||
// <auto-generated/>
|
||||
@@ -1207,22 +1223,6 @@ namespace Pal3.Command
|
||||
new UnknownCommand185(unknown1, unknown2, unknown3, unknown4, unknown5, unknown6, unknown7, unknown8));
|
||||
}
|
||||
|
||||
// <auto-generated/>
|
||||
[ConsoleMethodAttribute("Unknown188", "设置相机看向固定点???")]
|
||||
public static void Unknown188(System.Single unknown1, System.Single unknown2, System.Single unknown3, System.Int32 unknown4)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new UnknownCommand188(unknown1, unknown2, unknown3, unknown4));
|
||||
}
|
||||
|
||||
// <auto-generated/>
|
||||
[ConsoleMethodAttribute("Unknown189", "???")]
|
||||
public static void Unknown189(System.Int32 unknown)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new UnknownCommand189(unknown));
|
||||
}
|
||||
|
||||
// <auto-generated/>
|
||||
[ConsoleMethodAttribute("Unknown192", "南宫煌以变身状态下进入Boss战斗?")]
|
||||
public static void Unknown192(System.Int32 monster1Id, System.Int32 monster2Id, System.Int32 monster3Id, System.Int32 monster4Id, System.Int32 monster5Id, System.Int32 monster6Id, System.String combatMusic, System.Int32 unknown)
|
||||
@@ -1327,14 +1327,6 @@ namespace Pal3.Command
|
||||
new ResetGameStateCommand());
|
||||
}
|
||||
|
||||
// <auto-generated/>
|
||||
[ConsoleMethodAttribute("SceneSaveGlobalBidirectionalPushableObjectState", "Execute SceneSaveGlobalBidirectionalPushableObjectStateCommand.")]
|
||||
public static void SceneSaveGlobalBidirectionalPushableObjectState(System.String cityName, System.String sceneName, System.Int32 objectId, System.Int32 state)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new SceneSaveGlobalBidirectionalPushableObjectStateCommand(cityName, sceneName, objectId, state));
|
||||
}
|
||||
|
||||
// <auto-generated/>
|
||||
[ConsoleMethodAttribute("SceneSaveGlobalObjectActivationState", "Execute SceneSaveGlobalObjectActivationStateCommand.")]
|
||||
public static void SceneSaveGlobalObjectActivationState(System.String cityName, System.String sceneName, System.Int32 objectId, System.Boolean isActivated)
|
||||
@@ -1383,6 +1375,14 @@ namespace Pal3.Command
|
||||
new SceneSaveGlobalObjectYRotationCommand(cityName, sceneName, objectId, gameBoxYRotation));
|
||||
}
|
||||
|
||||
// <auto-generated/>
|
||||
[ConsoleMethodAttribute("SceneSaveGlobalThreePhaseSwitchState", "Execute SceneSaveGlobalThreePhaseSwitchStateCommand.")]
|
||||
public static void SceneSaveGlobalThreePhaseSwitchState(System.String cityName, System.String sceneName, System.Int32 objectId, System.Int32 previousState, System.Int32 currentState)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new SceneSaveGlobalThreePhaseSwitchStateCommand(cityName, sceneName, objectId, previousState, currentState));
|
||||
}
|
||||
|
||||
// <auto-generated/>
|
||||
[ConsoleMethodAttribute("ToggleBigMapRequest", "Execute ToggleBigMapRequest.")]
|
||||
public static void ToggleBigMapRequest()
|
||||
|
||||
@@ -312,19 +312,19 @@ namespace Pal3.Command
|
||||
}
|
||||
|
||||
// <auto-generated/>
|
||||
[ConsoleMethodAttribute("CameraFree", "取消镜头锁定")]
|
||||
public static void CameraFree(System.Int32 free)
|
||||
[ConsoleMethodAttribute("CameraFollowPlayer", "镜头是否锁定并跟随在主角身上,参数:1锁定并跟随,0解锁")]
|
||||
public static void CameraFollowPlayer(System.Int32 follow)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new CameraFreeCommand(free));
|
||||
new CameraFollowPlayerCommand(follow));
|
||||
}
|
||||
|
||||
// <auto-generated/>
|
||||
[ConsoleMethodAttribute("CameraMove", "镜头当前位置移动(保持当前角度),参数:原GameBox引擎下的一个三维坐标(X,Y,Z),动作时间,插值类型")]
|
||||
public static void CameraMove(System.Single gameBoxXPosition, System.Single gameBoxYPosition, System.Single gameBoxZPosition, System.Single duration, System.Int32 mode)
|
||||
public static void CameraMove(System.Single gameBoxXPosition, System.Single gameBoxYPosition, System.Single gameBoxZPosition, System.Single duration, System.Int32 curveType)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new CameraMoveCommand(gameBoxXPosition, gameBoxYPosition, gameBoxZPosition, duration, mode));
|
||||
new CameraMoveCommand(gameBoxXPosition, gameBoxYPosition, gameBoxZPosition, duration, curveType));
|
||||
}
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
@@ -10,7 +10,10 @@ namespace Pal3.Command.SceCommands
|
||||
"参数:原GameBox引擎下的一个三维坐标(X,Y,Z)")]
|
||||
public class CameraFocusOnPositionCommand : ICommand
|
||||
{
|
||||
public CameraFocusOnPositionCommand(float gameBoxXPosition, float gameBoxYPosition, float gameBoxZPosition)
|
||||
public CameraFocusOnPositionCommand(
|
||||
float gameBoxXPosition,
|
||||
float gameBoxYPosition,
|
||||
float gameBoxZPosition)
|
||||
{
|
||||
GameBoxXPosition = gameBoxXPosition;
|
||||
GameBoxYPosition = gameBoxYPosition;
|
||||
|
||||
+6
-5
@@ -6,14 +6,15 @@
|
||||
namespace Pal3.Command.SceCommands
|
||||
{
|
||||
[AvailableInConsole]
|
||||
[SceCommand(250, "取消镜头锁定")]
|
||||
public class CameraFreeCommand : ICommand
|
||||
[SceCommand(250, "镜头是否锁定并跟随在主角身上," +
|
||||
"参数:1锁定并跟随,0解锁")]
|
||||
public class CameraFollowPlayerCommand : ICommand
|
||||
{
|
||||
public CameraFreeCommand(int free)
|
||||
public CameraFollowPlayerCommand(int follow)
|
||||
{
|
||||
Free = free;
|
||||
Follow = follow;
|
||||
}
|
||||
|
||||
public int Free { get; }
|
||||
public int Follow { get; }
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -11,20 +11,25 @@ namespace Pal3.Command.SceCommands
|
||||
"参数:原GameBox引擎下的一个三维坐标(X,Y,Z),动作时间,插值类型")]
|
||||
public class CameraMoveCommand : ICommand
|
||||
{
|
||||
public CameraMoveCommand(float gameBoxXPosition, float gameBoxYPosition, float gameBoxZPosition, float duration, int mode)
|
||||
public CameraMoveCommand(
|
||||
float gameBoxXPosition,
|
||||
float gameBoxYPosition,
|
||||
float gameBoxZPosition,
|
||||
float duration,
|
||||
int curveType)
|
||||
{
|
||||
GameBoxXPosition = gameBoxXPosition;
|
||||
GameBoxYPosition = gameBoxYPosition;
|
||||
GameBoxZPosition = gameBoxZPosition;
|
||||
Duration = duration;
|
||||
Mode = mode;
|
||||
CurveType = curveType;
|
||||
}
|
||||
|
||||
public float GameBoxXPosition { get; }
|
||||
public float GameBoxYPosition { get; }
|
||||
public float GameBoxZPosition { get; }
|
||||
public float Duration { get; }
|
||||
public int Mode { get; }
|
||||
public int CurveType { get; }
|
||||
}
|
||||
#elif PAL3A
|
||||
[AvailableInConsole]
|
||||
@@ -32,13 +37,19 @@ namespace Pal3.Command.SceCommands
|
||||
"参数:原GameBox引擎下的一个三维坐标(X,Y,Z),动作时间,插值类型,同步(1暂停当前脚本运行,0异步进行动画且继续执行脚本)")]
|
||||
public class CameraMoveCommand : ICommand
|
||||
{
|
||||
public CameraMoveCommand(float gameBoxXPosition, float gameBoxYPosition, float gameBoxZPosition, float duration, int mode, int synchronous)
|
||||
public CameraMoveCommand(
|
||||
float gameBoxXPosition,
|
||||
float gameBoxYPosition,
|
||||
float gameBoxZPosition,
|
||||
float duration,
|
||||
int curveType,
|
||||
int synchronous)
|
||||
{
|
||||
GameBoxXPosition = gameBoxXPosition;
|
||||
GameBoxYPosition = gameBoxYPosition;
|
||||
GameBoxZPosition = gameBoxZPosition;
|
||||
Duration = duration;
|
||||
Mode = mode;
|
||||
CurveType = curveType;
|
||||
Synchronous = synchronous;
|
||||
}
|
||||
|
||||
@@ -46,7 +57,7 @@ namespace Pal3.Command.SceCommands
|
||||
public float GameBoxYPosition { get; }
|
||||
public float GameBoxZPosition { get; }
|
||||
public float Duration { get; }
|
||||
public int Mode { get; }
|
||||
public int CurveType { get; }
|
||||
public int Synchronous { get; }
|
||||
}
|
||||
#endif
|
||||
|
||||
+5
-5
@@ -7,15 +7,15 @@ namespace Pal3.Command.SceCommands
|
||||
{
|
||||
#if PAL3A
|
||||
[AvailableInConsole]
|
||||
[SceCommand(189, "???")]
|
||||
public class UnknownCommand189 : ICommand
|
||||
[SceCommand(189, "相机移动至默认焦距点(主角)")]
|
||||
public class CameraMoveToDefaultLookAtPointCommand : ICommand
|
||||
{
|
||||
public UnknownCommand189(int unknown)
|
||||
public CameraMoveToDefaultLookAtPointCommand(int duration)
|
||||
{
|
||||
Unknown = unknown;
|
||||
Duration = duration;
|
||||
}
|
||||
|
||||
public int Unknown { get; }
|
||||
public int Duration { get; }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,31 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.Command.SceCommands
|
||||
{
|
||||
#if PAL3A
|
||||
[AvailableInConsole]
|
||||
[SceCommand(188, "移动相机并看向固定点")]
|
||||
public class CameraMoveToLookAtPointCommand : ICommand
|
||||
{
|
||||
public CameraMoveToLookAtPointCommand(
|
||||
float gameBoxXPosition,
|
||||
float gameBoxYPosition,
|
||||
float gameBoxZPosition,
|
||||
int synchronous)
|
||||
{
|
||||
GameBoxXPosition = gameBoxXPosition;
|
||||
GameBoxYPosition = gameBoxYPosition;
|
||||
GameBoxZPosition = gameBoxZPosition;
|
||||
Synchronous = synchronous;
|
||||
}
|
||||
|
||||
public float GameBoxXPosition { get; }
|
||||
public float GameBoxYPosition { get; }
|
||||
public float GameBoxZPosition { get; }
|
||||
public int Synchronous { get; }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
File renamed without changes.
@@ -10,7 +10,11 @@ namespace Pal3.Command.SceCommands
|
||||
"参数:目标Yaw,Pitch,运动时间,插值类型(0:Linear,1:Sine)")]
|
||||
public class CameraOrbitCommand : ICommand
|
||||
{
|
||||
public CameraOrbitCommand(float yaw, float pitch, float duration, int curveType)
|
||||
public CameraOrbitCommand(
|
||||
float yaw,
|
||||
float pitch,
|
||||
float duration,
|
||||
int curveType)
|
||||
{
|
||||
Yaw = yaw;
|
||||
Pitch = pitch;
|
||||
|
||||
@@ -11,7 +11,13 @@ namespace Pal3.Command.SceCommands
|
||||
"参数:目标Yaw,Pitch,目标镜头距离(原GameBox引擎下的距离单位),运动时间,插值类型(0:Linear,1:Sine),同步(1暂停当前脚本运行,0异步进行动画且继续执行脚本)")]
|
||||
public class CameraOrbitHorizontalCommand : ICommand
|
||||
{
|
||||
public CameraOrbitHorizontalCommand(float yaw, float pitch, float gameBoxDistance, float duration, int curveType, int synchronous)
|
||||
public CameraOrbitHorizontalCommand(
|
||||
float yaw,
|
||||
float pitch,
|
||||
float gameBoxDistance,
|
||||
float duration,
|
||||
int curveType,
|
||||
int synchronous)
|
||||
{
|
||||
Yaw = yaw;
|
||||
Pitch = pitch;
|
||||
|
||||
@@ -11,7 +11,10 @@ namespace Pal3.Command.SceCommands
|
||||
"参数:最后from与lookAt之间的距离(原GameBox引擎下的距离单位),动作时间,插值类型(0:Linear,1:Sine)")]
|
||||
public class CameraPushCommand : ICommand
|
||||
{
|
||||
public CameraPushCommand(float gameBoxDistance, float duration, int curveType)
|
||||
public CameraPushCommand(
|
||||
float gameBoxDistance,
|
||||
float duration,
|
||||
int curveType)
|
||||
{
|
||||
GameBoxDistance = gameBoxDistance;
|
||||
Duration = duration;
|
||||
@@ -28,7 +31,11 @@ namespace Pal3.Command.SceCommands
|
||||
"参数:最后from与lookAt之间的距离(原GameBox引擎下的距离单位),动作时间,插值类型(0:Linear,1:Sine),同步(1暂停当前脚本运行,0异步进行动画且继续执行脚本)")]
|
||||
public class CameraPushCommand : ICommand
|
||||
{
|
||||
public CameraPushCommand(float gameBoxDistance, float duration, int curveType, int synchronous)
|
||||
public CameraPushCommand(
|
||||
float gameBoxDistance,
|
||||
float duration,
|
||||
int curveType,
|
||||
int synchronous)
|
||||
{
|
||||
GameBoxDistance = gameBoxDistance;
|
||||
Duration = duration;
|
||||
|
||||
@@ -11,7 +11,11 @@ namespace Pal3.Command.SceCommands
|
||||
"参数:目标Yaw,Pitch,运动时间,插值类型(0:Linear,1:Sine)")]
|
||||
public class CameraRotateCommand : ICommand
|
||||
{
|
||||
public CameraRotateCommand(float yaw, float pitch, float duration, int curveType)
|
||||
public CameraRotateCommand(
|
||||
float yaw,
|
||||
float pitch,
|
||||
float duration,
|
||||
int curveType)
|
||||
{
|
||||
Yaw = yaw;
|
||||
Pitch = pitch;
|
||||
@@ -30,7 +34,12 @@ namespace Pal3.Command.SceCommands
|
||||
"参数:目标Yaw,Pitch,运动时间,插值类型(0:Linear,1:Sine),同步(1暂停当前脚本运行,0异步进行动画且继续执行脚本)")]
|
||||
public class CameraRotateCommand : ICommand
|
||||
{
|
||||
public CameraRotateCommand(float yaw, float pitch, float duration, int curveType, int synchronous)
|
||||
public CameraRotateCommand(
|
||||
float yaw,
|
||||
float pitch,
|
||||
float duration,
|
||||
int curveType,
|
||||
int synchronous)
|
||||
{
|
||||
Yaw = yaw;
|
||||
Pitch = pitch;
|
||||
|
||||
@@ -10,7 +10,8 @@ namespace Pal3.Command.SceCommands
|
||||
"参数:Yaw,Pitch,Distance(原GameBox引擎下的距离单位),原GameBox引擎下的一个三维坐标(X,Y,Z)")]
|
||||
public class CameraSetTransformCommand : ICommand
|
||||
{
|
||||
public CameraSetTransformCommand(float yaw,
|
||||
public CameraSetTransformCommand(
|
||||
float yaw,
|
||||
float pitch,
|
||||
float gameBoxDistance,
|
||||
float gameBoxXPosition,
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.Command.SceCommands
|
||||
{
|
||||
#if PAL3A
|
||||
[AvailableInConsole]
|
||||
[SceCommand(188, "设置相机看向固定点???")]
|
||||
public class UnknownCommand188 : ICommand
|
||||
{
|
||||
public UnknownCommand188(float unknown1,
|
||||
float unknown2,
|
||||
float unknown3,
|
||||
int unknown4)
|
||||
{
|
||||
Unknown1 = unknown1;
|
||||
Unknown2 = unknown2;
|
||||
Unknown3 = unknown3;
|
||||
Unknown4 = unknown4;
|
||||
}
|
||||
|
||||
public float Unknown1 { get; }
|
||||
public float Unknown2 { get; }
|
||||
public float Unknown3 { get; }
|
||||
public int Unknown4 { get; }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1019,14 +1019,6 @@ namespace Pal3.Dev
|
||||
_mazeSkipperCanvasGroup.alpha = 0f;
|
||||
_mazeSkipperCanvasGroup.interactable = false;
|
||||
}
|
||||
|
||||
// TODO: Remove when all scene objects are implemented for PAL3A
|
||||
#if PAL3A
|
||||
if (command.NewSceneInfo.SceneType == ScnSceneType.Maze)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new UIDisplayNoteCommand("外传迷宫中的部分机关还未实现,敬请期待!"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1051,6 +1051,10 @@ namespace Pal3.Dev
|
||||
ActorSetTilePosition -1 342 137
|
||||
TeamAddOrRemoveActor 0 1
|
||||
TeamAddOrRemoveActor 1 1
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"绿萝山-蜀山", @"
|
||||
ScriptVarSetValue -32768 30900
|
||||
@@ -1068,6 +1072,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 2 2
|
||||
BigMapEnableRegion 4 2
|
||||
BigMapEnableRegion 5 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"地脉门户-少阳三焦", @"
|
||||
ScriptVarSetValue -32768 40200
|
||||
@@ -1084,6 +1092,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 2 2
|
||||
BigMapEnableRegion 4 2
|
||||
BigMapEnableRegion 5 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"第一次进入里蜀山", @"
|
||||
ScriptVarSetValue -32768 41100
|
||||
@@ -1102,6 +1114,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 4 2
|
||||
BigMapEnableRegion 5 2
|
||||
BigMapEnableRegion 6 1
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"打完狸猫回废屋休息", @"
|
||||
ScriptVarSetValue -32768 41600
|
||||
@@ -1120,6 +1136,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 4 2
|
||||
BigMapEnableRegion 5 2
|
||||
BigMapEnableRegion 6 1
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"里蜀山外城南-厥阴心包", @"
|
||||
ScriptVarSetValue -32768 50200
|
||||
@@ -1138,6 +1158,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 4 2
|
||||
BigMapEnableRegion 5 2
|
||||
BigMapEnableRegion 6 1
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"厥阴心包-胜州", @"
|
||||
ScriptVarSetValue -32768 50500
|
||||
@@ -1156,6 +1180,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 4 2
|
||||
BigMapEnableRegion 5 2
|
||||
BigMapEnableRegion 6 1
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"胜州祭坛欢庆盛典", @"
|
||||
ScriptVarSetValue -32768 51100
|
||||
@@ -1177,6 +1205,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 6 1
|
||||
BigMapEnableRegion 7 2
|
||||
BigMapEnableRegion 8 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"胜州-蜀山", @"
|
||||
ScriptVarSetValue -32768 60100
|
||||
@@ -1198,6 +1230,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 6 1
|
||||
BigMapEnableRegion 7 2
|
||||
BigMapEnableRegion 8 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"蜀山-深夜去经库", @"
|
||||
ScriptVarSetValue -32768 60500
|
||||
@@ -1218,6 +1254,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 6 1
|
||||
BigMapEnableRegion 7 2
|
||||
BigMapEnableRegion 8 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"地脉门户大厅-阳名百纳", @"
|
||||
ScriptVarSetValue -32768 70100
|
||||
@@ -1237,6 +1277,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 6 1
|
||||
BigMapEnableRegion 7 2
|
||||
BigMapEnableRegion 8 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"血濡回魂-初入京城", @"
|
||||
ScriptVarSetValue -32768 70700
|
||||
@@ -1256,6 +1300,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 7 2
|
||||
BigMapEnableRegion 8 2
|
||||
BigMapEnableRegion 9 1
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"血濡回魂-蜀山深夜", @"
|
||||
ScriptVarSetValue -32768 71501
|
||||
@@ -1275,6 +1323,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 7 2
|
||||
BigMapEnableRegion 8 2
|
||||
BigMapEnableRegion 9 1
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"血濡回魂-梦醒", @"
|
||||
ScriptVarSetValue -32768 72001
|
||||
@@ -1295,6 +1347,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 8 2
|
||||
BigMapEnableRegion 9 1
|
||||
BigMapEnableRegion 10 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"失散-双溪", @"
|
||||
ScriptVarSetValue -32768 80100
|
||||
@@ -1317,6 +1373,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 8 2
|
||||
BigMapEnableRegion 9 1
|
||||
BigMapEnableRegion 10 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"双溪-里蜀山", @"
|
||||
ScriptVarSetValue -32768 80700
|
||||
@@ -1340,6 +1400,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 8 2
|
||||
BigMapEnableRegion 9 1
|
||||
BigMapEnableRegion 10 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"里蜀山外城南-太阴归尘", @"
|
||||
ScriptVarSetValue -32768 80700
|
||||
@@ -1363,6 +1427,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 8 2
|
||||
BigMapEnableRegion 9 1
|
||||
BigMapEnableRegion 10 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"太阴归尘-蜀山故道", @"
|
||||
ScriptVarSetValue -32768 90300
|
||||
@@ -1384,6 +1452,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 8 2
|
||||
BigMapEnableRegion 9 1
|
||||
BigMapEnableRegion 10 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"蜀山故道-蜀山", @"
|
||||
ScriptVarSetValue -32768 91000
|
||||
@@ -1405,6 +1477,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 8 2
|
||||
BigMapEnableRegion 9 1
|
||||
BigMapEnableRegion 10 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"蜀山深夜-养父常纪房间", @"
|
||||
ScriptVarSetValue -32768 100400
|
||||
@@ -1428,6 +1504,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 9 1
|
||||
BigMapEnableRegion 10 2
|
||||
BigMapEnableRegion 11 1
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"无极阁找掌门去锁妖塔", @"
|
||||
ScriptVarSetValue -32768 100701
|
||||
@@ -1452,6 +1532,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 10 2
|
||||
BigMapEnableRegion 11 1
|
||||
CameraSetDefaultTransform 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"新安当", @"
|
||||
ScriptVarSetValue -32768 101500
|
||||
@@ -1477,6 +1561,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 12 1
|
||||
BigMapEnableRegion 13 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"蜀山回无极阁", @"
|
||||
ScriptVarSetValue -32768 101600
|
||||
@@ -1500,6 +1588,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 10 2
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 13 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"地脉门户-太阳华池", @"
|
||||
ScriptVarSetValue -32768 110200
|
||||
@@ -1522,6 +1614,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 10 2
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 13 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"小秘屋会和", @"
|
||||
ScriptVarSetValue -32768 120300
|
||||
@@ -1545,6 +1641,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 10 2
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 13 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"里蜀山-魔界之门", @"
|
||||
ScriptVarSetValue -32768 120400
|
||||
@@ -1569,6 +1669,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 10 2
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 13 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"回秘密基地看望星璇", @"
|
||||
ScriptVarSetValue -32768 121100
|
||||
@@ -1593,6 +1697,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 10 2
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 13 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"里蜀山外城北-少阴凝碧", @"
|
||||
ScriptVarSetValue -32768 130100
|
||||
@@ -1617,6 +1725,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 10 2
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 13 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"施洞", @"
|
||||
ScriptVarSetValue -32768 140200
|
||||
@@ -1642,6 +1754,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 10 2
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 13 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"出发去月光城", @"
|
||||
ScriptVarSetValue -32768 140400
|
||||
@@ -1650,7 +1766,7 @@ namespace Pal3.Dev
|
||||
ActorEnablePlayerControl -1
|
||||
PlayerEnableInput 1
|
||||
ActorSetNavLayer -1 0
|
||||
ActorSetTilePosition -1 301 192
|
||||
ActorSetTilePosition -1 144 53
|
||||
TeamAddOrRemoveActor 0 1
|
||||
TeamAddOrRemoveActor 1 1
|
||||
TeamAddOrRemoveActor 2 1
|
||||
@@ -1667,6 +1783,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 10 2
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 13 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"从施洞回到蜀山", @"
|
||||
ScriptVarSetValue -32768 150100
|
||||
@@ -1692,6 +1812,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 13 2
|
||||
BigMapEnableRegion 14 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"蜀山-绿萝山", @"
|
||||
ScriptVarSetValue -32768 150300
|
||||
@@ -1717,6 +1841,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 13 2
|
||||
BigMapEnableRegion 14 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"地脉门户-少阳参天", @"
|
||||
ScriptVarSetValue -32768 150400
|
||||
@@ -1741,6 +1869,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 13 2
|
||||
BigMapEnableRegion 14 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"回里蜀山秘密基地", @"
|
||||
ScriptVarSetValue -32768 160101
|
||||
@@ -1766,6 +1898,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 13 2
|
||||
BigMapEnableRegion 14 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"里蜀山见燎日", @"
|
||||
ScriptVarSetValue -32768 161200
|
||||
@@ -1792,6 +1928,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 13 2
|
||||
BigMapEnableRegion 14 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"里蜀山内城到厥阴蔽日", @"
|
||||
ScriptVarSetValue -32768 170200
|
||||
@@ -1818,6 +1958,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 13 2
|
||||
BigMapEnableRegion 14 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"地脉门户-蜀山前山", @"
|
||||
ScriptVarSetValue -32768 171200
|
||||
@@ -1842,6 +1986,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 11 1
|
||||
BigMapEnableRegion 13 2
|
||||
BigMapEnableRegion 14 2
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"花圃找王蓬絮\n(温慧好感度最高)", @"
|
||||
ScriptVarSetValue -32768 180600
|
||||
@@ -1868,6 +2016,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 14 2
|
||||
FavorAdd 1 50
|
||||
FavorAdd 2 10
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
{"花圃找王蓬絮\n(王蓬絮好感度最高)", @"
|
||||
ScriptVarSetValue -32768 180600
|
||||
@@ -1894,6 +2046,10 @@ namespace Pal3.Dev
|
||||
BigMapEnableRegion 14 2
|
||||
FavorAdd 1 10
|
||||
FavorAdd 2 50
|
||||
SceneSaveGlobalObjectSwitchState m02 1 35 1
|
||||
SceneSaveGlobalObjectTimesCount m02 1 35 0
|
||||
SceneSaveGlobalObjectActivationState m02 1 36 False
|
||||
SceneSaveGlobalObjectSwitchState m02 1 36 1
|
||||
CameraFadeIn"},
|
||||
#endif
|
||||
};
|
||||
@@ -1994,8 +2150,10 @@ namespace Pal3.Dev
|
||||
var buttonTextUI = selectionButton.GetComponentInChildren<TextMeshProUGUI>();
|
||||
buttonTextUI.text = story.Key;
|
||||
|
||||
ButtonType buttonType = ButtonType.Normal;
|
||||
if (story.Key is "关闭" or "保存当前游戏进度" or "退出游戏" or "新的游戏" or "继续游戏")
|
||||
{
|
||||
buttonType = ButtonType.Highlighted;
|
||||
buttonTextUI.fontStyle = FontStyles.Underline;
|
||||
}
|
||||
|
||||
@@ -2003,7 +2161,7 @@ namespace Pal3.Dev
|
||||
Navigation buttonNavigation = button.navigation;
|
||||
buttonNavigation.mode = Navigation.Mode.Horizontal | Navigation.Mode.Vertical;
|
||||
button.navigation = buttonNavigation;
|
||||
button.colors = UITheme.GetButtonColors();
|
||||
button.colors = UITheme.GetButtonColors(buttonType);
|
||||
button.onClick.AddListener(delegate { StorySelectionButtonClicked(story.Key);});
|
||||
_selectionButtons.Add(selectionButton);
|
||||
}
|
||||
|
||||
@@ -329,6 +329,7 @@ namespace Pal3
|
||||
DebugLogConsole.AddCommand("state", "Get current game state in commands form.", PrintCurrentGameStateInCommandsForm);
|
||||
DebugLogConsole.AddCommand("info", "Get current game info.", PrintCurrentGameInfo);
|
||||
DebugLogConsole.AddCommand<int>("fps", "Set target FPS.", SetTargetFps);
|
||||
DebugLogConsole.AddCommand<float>("fov", "Set camera FOV.", SetCameraFov);
|
||||
|
||||
DisableInGameDebugConsoleButtonNavigation();
|
||||
|
||||
@@ -462,5 +463,10 @@ namespace Pal3
|
||||
{
|
||||
Application.targetFrameRate = targetFps;
|
||||
}
|
||||
|
||||
private void SetCameraFov(float fieldOfView)
|
||||
{
|
||||
mainCamera.fieldOfView = fieldOfView;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -564,7 +564,7 @@ namespace Pal3.Player
|
||||
{
|
||||
//Debug.DrawLine(actorCenterPosition, closetPointOnObject, Color.white, 1000);
|
||||
nearestInteractableFacingAngle = facingAngle;
|
||||
interactionRoutine = InteractWithSceneObjectAsync(sceneObject);
|
||||
interactionRoutine = InteractWithSceneObjectAsync(sceneObject, startedByPlayer: true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,7 +601,7 @@ namespace Pal3.Player
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator InteractWithSceneObjectAsync(SceneObject sceneObject)
|
||||
private IEnumerator InteractWithSceneObjectAsync(SceneObject sceneObject, bool startedByPlayer)
|
||||
{
|
||||
var correlationId = Guid.NewGuid();
|
||||
var requiresStateChange = sceneObject.ShouldGoToCutsceneWhenInteractionStarted();
|
||||
@@ -617,7 +617,8 @@ namespace Pal3.Player
|
||||
CorrelationId = correlationId,
|
||||
InitObjectId = sceneObject.ObjectInfo.Id,
|
||||
PlayerActorGameObject = _playerActorGameObject,
|
||||
CurrentScene = _sceneManager.GetCurrentScene()
|
||||
CurrentScene = _sceneManager.GetCurrentScene(),
|
||||
StartedByPlayer = startedByPlayer,
|
||||
});
|
||||
|
||||
if (requiresStateChange)
|
||||
@@ -836,7 +837,8 @@ namespace Pal3.Player
|
||||
Scene currentScene = _sceneManager.GetCurrentScene();
|
||||
if (currentScene.GetAllActivatedSceneObjects().Contains(command.SceneObjectId))
|
||||
{
|
||||
StartCoroutine(InteractWithSceneObjectAsync(currentScene.GetSceneObject(command.SceneObjectId)));
|
||||
StartCoroutine(InteractWithSceneObjectAsync(
|
||||
currentScene.GetSceneObject(command.SceneObjectId), startedByPlayer: false));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -116,7 +116,11 @@ namespace Pal3.Renderer
|
||||
var textures = new List<(string name, Texture2D texture)>();
|
||||
foreach (var textureName in mesh.Textures[i].TextureNames)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textureName)) continue;
|
||||
if (string.IsNullOrEmpty(textureName))
|
||||
{
|
||||
textures.Add((textureName, Texture2D.whiteTexture));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_textureCache.ContainsKey(textureName))
|
||||
{
|
||||
|
||||
@@ -289,18 +289,18 @@ namespace Pal3.Scene
|
||||
private void SetupEnvironmentLighting()
|
||||
{
|
||||
Vector3 mainLightPosition = new Vector3(0, 20f, 0);
|
||||
Quaternion mainLightRotation = ScnFile.SceneInfo.SceneType == ScnSceneType.StoryB ?
|
||||
Quaternion mainLightRotation = ScnFile.SceneInfo.SceneType == ScnSceneType.InDoor ?
|
||||
Quaternion.Euler(120f, -20f, 0f) :
|
||||
Quaternion.Euler(70f, -30f, 0f);
|
||||
|
||||
if (ScnFile.SceneInfo.SceneType == ScnSceneType.StoryB && IsNightScene())
|
||||
if (ScnFile.SceneInfo.SceneType == ScnSceneType.InDoor && IsNightScene())
|
||||
{
|
||||
mainLightRotation = Quaternion.Euler(90f, 0f, 0f);
|
||||
}
|
||||
|
||||
// Most in-door scenes have a single spot light source where we can find in the LGT file,
|
||||
// which can be used as the main light source for the scene.
|
||||
// if (ScnFile.SceneInfo.SceneType == ScnSceneType.StoryB &&
|
||||
// if (ScnFile.SceneInfo.SceneType == ScnSceneType.InDoor &&
|
||||
// LgtFile.LightNodes.FirstOrDefault(_ => _.LightType == GameBoxLightType.Spot) is var mainLight)
|
||||
// {
|
||||
// float w = Mathf.Sqrt(1.0f + mainLight.WorldMatrix.m00 + mainLight.WorldMatrix.m11 + mainLight.WorldMatrix.m22) / 2.0f;
|
||||
@@ -329,12 +329,12 @@ namespace Pal3.Scene
|
||||
_mainLight.color = IsNightScene() ?
|
||||
new Color(60f / 255f, 80f / 255f, 170f / 255f) :
|
||||
new Color(220f / 255f, 210f / 255f, 200f / 255f);
|
||||
_mainLight.intensity = (IsNightScene() || ScnFile.SceneInfo.SceneType == ScnSceneType.StoryB) ? 0.75f : 1f;
|
||||
_mainLight.intensity = (IsNightScene() || ScnFile.SceneInfo.SceneType == ScnSceneType.InDoor) ? 0.75f : 1f;
|
||||
#elif PAL3A
|
||||
_mainLight.color = IsNightScene() ?
|
||||
new Color(60f / 255f, 80f / 255f, 170f / 255f) :
|
||||
new Color(200f / 255f, 200f / 255f, 200f / 255f);
|
||||
_mainLight.intensity = (IsNightScene() || ScnFile.SceneInfo.SceneType == ScnSceneType.StoryB) ? 0.65f : 1f;
|
||||
_mainLight.intensity = (IsNightScene() || ScnFile.SceneInfo.SceneType == ScnSceneType.InDoor) ? 0.65f : 1f;
|
||||
#endif
|
||||
|
||||
// Ambient light
|
||||
|
||||
@@ -6,9 +6,12 @@
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
using Command;
|
||||
using Command.SceCommands;
|
||||
using Common;
|
||||
using Core.DataReader.Scn;
|
||||
using Data;
|
||||
using MetaData;
|
||||
using UnityEngine;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.AutoTrigger)]
|
||||
@@ -29,14 +32,31 @@ namespace Pal3.Scene.SceneObjects
|
||||
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
// This is to prevent player from entering back to previous
|
||||
// scene when holding the stick while transferring between scenes.
|
||||
// We simply disable the auto trigger for a short time window after
|
||||
// a fresh scene load.
|
||||
var effectiveTime = Time.realtimeSinceStartupAsDouble + 0.4f;
|
||||
_triggerController = sceneGameObject.AddComponent<TilemapTriggerController>();
|
||||
_triggerController.Init(ObjectInfo.TileMapTriggerRect, ObjectInfo.LayerIndex, effectiveTime);
|
||||
_triggerController.OnPlayerActorEntered += OnPlayerActorEntered;
|
||||
if (ObjectInfo.TileMapTriggerRect.IsEmpty)
|
||||
{
|
||||
if (ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
GetCvdModelRenderer().LoopAnimation();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is to prevent player from entering back to previous
|
||||
// scene when holding the stick while transferring between scenes.
|
||||
// We simply disable the auto trigger for a short time window after
|
||||
// a fresh scene load.
|
||||
var effectiveTime = Time.realtimeSinceStartupAsDouble + 0.4f;
|
||||
_triggerController = sceneGameObject.AddComponent<TilemapTriggerController>();
|
||||
_triggerController.Init(ObjectInfo.TileMapTriggerRect, ObjectInfo.LayerIndex, effectiveTime);
|
||||
_triggerController.OnPlayerActorEntered += OnPlayerActorEntered;
|
||||
}
|
||||
|
||||
#if PAL3A
|
||||
if (ObjectInfo.Parameters[2] == 1 && GraphicsEffect == GraphicsEffect.Portal)
|
||||
{
|
||||
sceneGameObject.transform.rotation *= Quaternion.Euler(180, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
@@ -53,13 +73,26 @@ namespace Pal3.Scene.SceneObjects
|
||||
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
yield return ExecuteScriptAndWaitForFinishIfAnyAsync();
|
||||
if (ObjectInfo.LinkedObjectId != INVALID_SCENE_OBJECT_ID)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID));
|
||||
ExecuteScriptIfAny();
|
||||
yield return ActivateOrInteractWithObjectIfAnyAsync(ctx, ObjectInfo.LinkedObjectId);
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return ExecuteScriptAndWaitForFinishIfAnyAsync();
|
||||
}
|
||||
|
||||
_isInteractionInProgress = false;
|
||||
}
|
||||
|
||||
public override bool ShouldGoToCutsceneWhenInteractionStarted()
|
||||
{
|
||||
return false; // Do not go to cutscene when auto trigger is executed, let the script decide.
|
||||
// If object has a linked object, we should go to cutscene
|
||||
// else we should not.
|
||||
return ObjectInfo.LinkedObjectId != INVALID_SCENE_OBJECT_ID;
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
[ScnSceneObject(ScnSceneObjectType.Chest)]
|
||||
public sealed class ChestObject : SceneObject
|
||||
{
|
||||
private const float MAX_INTERACTION_DISTANCE = 4f;
|
||||
private const float MAX_INTERACTION_DISTANCE = 3f;
|
||||
|
||||
private SceneObjectMeshCollider _meshCollider;
|
||||
|
||||
@@ -48,7 +48,20 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (!IsInteractableBasedOnTimesCount()) yield break;
|
||||
|
||||
PlaySfx("wg011");
|
||||
PlaySfx("wa006");
|
||||
|
||||
if (ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
GetCvdModelRenderer().StartOneTimeAnimation(true, 1f, () =>
|
||||
{
|
||||
ExecuteScriptIfAny();
|
||||
ChangeAndSaveActivationState(false);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ExecuteScriptIfAny();
|
||||
ChangeAndSaveActivationState(false);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
@@ -65,19 +78,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
GetCvdModelRenderer().StartOneTimeAnimation(true, 1f, () =>
|
||||
{
|
||||
ExecuteScriptIfAny();
|
||||
ChangeAndSaveActivationState(false);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ExecuteScriptIfAny();
|
||||
ChangeAndSaveActivationState(false);
|
||||
}
|
||||
PlaySfx("wa006");
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
[ScnSceneObject(ScnSceneObjectType.Climbable)]
|
||||
public sealed class ClimbableObject : SceneObject
|
||||
{
|
||||
private const float MAX_INTERACTION_DISTANCE = 6f;
|
||||
private const float MAX_INTERACTION_DISTANCE = 5f;
|
||||
|
||||
private readonly PlayerGamePlayController _playerGamePlayController;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
[ScnSceneObject(ScnSceneObjectType.Collectable)]
|
||||
public sealed class CollectableObject : SceneObject
|
||||
{
|
||||
private const float MAX_INTERACTION_DISTANCE = 4f;
|
||||
private const float MAX_INTERACTION_DISTANCE = 3f;
|
||||
|
||||
public CollectableObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
using Common;
|
||||
using Core.DataReader.Scn;
|
||||
using Data;
|
||||
using Renderer;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
@@ -35,11 +36,17 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (ObjectInfo.SwitchState == 0)
|
||||
{
|
||||
_triggerController = sceneGameObject.AddComponent<BoundsTriggerController>();
|
||||
_triggerController.SetupCollider(GetMeshBounds(), ObjectInfo.IsNonBlocking == 1);
|
||||
_triggerController.SetBounds(GetMeshBounds(), ObjectInfo.IsNonBlocking == 1);
|
||||
_triggerController.OnPlayerActorEntered += OnPlayerActorEntered;
|
||||
}
|
||||
else
|
||||
else if (ObjectInfo.SwitchState == 1)
|
||||
{
|
||||
if (ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
CvdModelRenderer cvdModelRenderer = GetCvdModelRenderer();
|
||||
cvdModelRenderer.SetCurrentTime(cvdModelRenderer.GetDefaultAnimationDuration());
|
||||
}
|
||||
|
||||
if (ObjectInfo.IsNonBlocking == 0)
|
||||
{
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
@@ -63,7 +70,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
|
||||
if (!IsInteractableBasedOnTimesCount()) yield break;
|
||||
|
||||
ToggleAndSaveSwitchState();
|
||||
FlipAndSaveSwitchState();
|
||||
|
||||
PlaySfxIfAny();
|
||||
|
||||
@@ -74,7 +81,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
yield return ExecuteScriptAndWaitForFinishIfAnyAsync();
|
||||
|
||||
// Reset collider since bounds may change after animation
|
||||
_triggerController.SetupCollider(GetMeshBounds(), ObjectInfo.IsNonBlocking == 1);
|
||||
_triggerController.SetBounds(GetMeshBounds(), ObjectInfo.IsNonBlocking == 1);
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Pal3.Scene.SceneObjects.Common
|
||||
|
||||
private PlayerManager _playerManager;
|
||||
|
||||
public void SetupCollider(Bounds bounds, bool isTrigger)
|
||||
public void SetBounds(Bounds bounds, bool isTrigger)
|
||||
{
|
||||
if (_collider == null)
|
||||
{
|
||||
@@ -55,12 +55,12 @@ namespace Pal3.Scene.SceneObjects.Common
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider collider)
|
||||
private void OnTriggerEnter(Collider otherCollider)
|
||||
{
|
||||
if (collider.gameObject.GetComponent<ActorController>() is {} actorController &&
|
||||
if (otherCollider.gameObject.GetComponent<ActorController>() is {} actorController &&
|
||||
actorController.GetActor().Info.Id == (byte) _playerManager.GetPlayerActor())
|
||||
{
|
||||
OnPlayerActorEntered?.Invoke(this, collider.gameObject);
|
||||
OnPlayerActorEntered?.Invoke(this, otherCollider.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,12 +73,12 @@ namespace Pal3.Scene.SceneObjects.Common
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider collider)
|
||||
private void OnTriggerExit(Collider otherCollider)
|
||||
{
|
||||
if (collider.gameObject.GetComponent<ActorController>() is {} actorController &&
|
||||
if (otherCollider.gameObject.GetComponent<ActorController>() is {} actorController &&
|
||||
actorController.GetActor().Info.Id == (byte) _playerManager.GetPlayerActor())
|
||||
{
|
||||
OnPlayerActorExited?.Invoke(this, collider.gameObject);
|
||||
OnPlayerActorExited?.Invoke(this, otherCollider.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,24 +12,31 @@ namespace Pal3.Scene.SceneObjects.Common
|
||||
{
|
||||
private BoxCollider _collider;
|
||||
private Vector3 _meshBoundsSize;
|
||||
private float _boundsScale = 1.0f;
|
||||
private Vector3 _boundsSizeOffset;
|
||||
|
||||
public void SetBoundsScale(float boundsScale)
|
||||
private bool _initialized;
|
||||
|
||||
/// <summary>
|
||||
/// Init with a size offset.
|
||||
/// Note: This method is not required to be called.
|
||||
/// </summary>
|
||||
/// <param name="sizeOffset">A size offset to the bounds based on model</param>
|
||||
public void Init(Vector3 sizeOffset)
|
||||
{
|
||||
_boundsScale = boundsScale;
|
||||
|
||||
if (_collider != null)
|
||||
{
|
||||
_collider.size = _meshBoundsSize * _boundsScale;
|
||||
}
|
||||
_boundsSizeOffset = sizeOffset;
|
||||
UpdateBounds();
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
UpdateBounds();
|
||||
if (!_initialized)
|
||||
{
|
||||
UpdateBounds();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateBounds()
|
||||
private void UpdateBounds()
|
||||
{
|
||||
Bounds bounds;
|
||||
|
||||
@@ -54,7 +61,7 @@ namespace Pal3.Scene.SceneObjects.Common
|
||||
_meshBoundsSize = bounds.size;
|
||||
|
||||
_collider.center = bounds.center;
|
||||
_collider.size = _meshBoundsSize * _boundsScale;
|
||||
_collider.size = _meshBoundsSize + _boundsSizeOffset;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Pal3.Scene.SceneObjects.Common
|
||||
|
||||
private BoxCollider _collider;
|
||||
private Bounds _triggerBounds;
|
||||
private float _heightOffset;
|
||||
private float _platformHeightOffset;
|
||||
|
||||
private PlayerManager _playerManager;
|
||||
|
||||
@@ -29,11 +29,11 @@ namespace Pal3.Scene.SceneObjects.Common
|
||||
_playerManager = ServiceLocator.Instance.Get<PlayerManager>();
|
||||
}
|
||||
|
||||
public void SetBounds(Bounds triggerBounds, int layerIndex, float heightOffset = 0f)
|
||||
public void Init(Bounds triggerBounds, int layerIndex, float platformHeightOffset = 0f)
|
||||
{
|
||||
_triggerBounds = triggerBounds;
|
||||
LayerIndex = layerIndex;
|
||||
_heightOffset = heightOffset;
|
||||
_platformHeightOffset = platformHeightOffset;
|
||||
|
||||
if (_collider == null)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ namespace Pal3.Scene.SceneObjects.Common
|
||||
{
|
||||
// A little bit lower than the collider bounds just to make sure
|
||||
// the actor is always inside the collider when standing on the platform.
|
||||
return _collider.bounds.max.y - 0.05f + _heightOffset;
|
||||
return _collider.bounds.max.y + _platformHeightOffset - 0.05f;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider otherCollider)
|
||||
|
||||
@@ -26,9 +26,7 @@ namespace Pal3.Scene.SceneObjects.Common
|
||||
|
||||
public void Init(GameBoxRect tileMapTriggerRect, int layerIndex)
|
||||
{
|
||||
_tileMapTriggerRect = tileMapTriggerRect;
|
||||
_layerIndex = layerIndex;
|
||||
_effectiveTime = Time.realtimeSinceStartupAsDouble;
|
||||
Init(tileMapTriggerRect, layerIndex, Time.realtimeSinceStartupAsDouble);
|
||||
}
|
||||
|
||||
public void Init(GameBoxRect tileMapTriggerRect, int layerIndex, double effectiveTime)
|
||||
|
||||
@@ -12,14 +12,15 @@ namespace Pal3.Scene.SceneObjects
|
||||
/// Disabled scene objects will not be loaded to the scene.
|
||||
/// </summary>
|
||||
[ScnSceneObject(ScnSceneObjectType.SavingPoint)]
|
||||
#if PAL3
|
||||
[ScnSceneObject(ScnSceneObjectType.WishPool)]
|
||||
#endif
|
||||
[ScnSceneObject(ScnSceneObjectType.FallableWeapon)]
|
||||
[ScnSceneObject(ScnSceneObjectType.Arrow)]
|
||||
[ScnSceneObject(ScnSceneObjectType.ColdWeapon)]
|
||||
[ScnSceneObject(ScnSceneObjectType.WindBlower)]
|
||||
[ScnSceneObject(ScnSceneObjectType.Billboard)]
|
||||
[ScnSceneObject(ScnSceneObjectType.PreciseTrigger)]
|
||||
[ScnSceneObject(ScnSceneObjectType.RotatingWall)]
|
||||
public sealed class DisabledSceneObject : SceneObject
|
||||
{
|
||||
public DisabledSceneObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System;
|
||||
@@ -62,7 +64,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
};
|
||||
|
||||
_platformController = sceneGameObject.AddComponent<StandingPlatformController>();
|
||||
_platformController.SetBounds(bounds, ObjectInfo.LayerIndex);
|
||||
_platformController.Init(bounds, ObjectInfo.LayerIndex);
|
||||
}
|
||||
|
||||
return sceneGameObject;
|
||||
@@ -78,4 +80,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,8 +3,6 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
@@ -47,7 +45,8 @@ namespace Pal3.Scene.SceneObjects
|
||||
};
|
||||
|
||||
_platformController = sceneGameObject.AddComponent<StandingPlatformController>();
|
||||
_platformController.SetBounds(bounds, ObjectInfo.LayerIndex);
|
||||
_platformController.Init(bounds, ObjectInfo.LayerIndex);
|
||||
|
||||
_platformController.OnPlayerActorEntered += OnPlayerActorEntered;
|
||||
_platformController.OnPlayerActorExited += OnPlayerActorExited;
|
||||
|
||||
@@ -58,9 +57,13 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
if (_isInteractionInProgress) return;
|
||||
|
||||
#if PAL3
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new UIDisplayNoteCommand("等待三秒后,根据当前人物,会向上或向下传送哦。"));
|
||||
|
||||
#elif PAL3A
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new UIDisplayNoteCommand("等待三秒后,会开始传送哦。"));
|
||||
#endif
|
||||
_cancellationTokenSource.Cancel();
|
||||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
Pal3.Instance.StartCoroutine(CountDownForInteractionAsync(_cancellationTokenSource.Token));
|
||||
@@ -82,6 +85,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
#if PAL3
|
||||
var upperLevelScriptId = ObjectInfo.Parameters[0];
|
||||
var lowerLevelScriptId = ObjectInfo.Parameters[1];
|
||||
|
||||
@@ -101,13 +105,15 @@ namespace Pal3.Scene.SceneObjects
|
||||
shouldGoUp = (PlayerActorId) ctx.PlayerActorGameObject.GetComponent<ActorController>().GetActor().Info.Id is
|
||||
PlayerActorId.JingTian or PlayerActorId.XueJian;
|
||||
}
|
||||
#elif PAL3A
|
||||
bool? shouldGoUp = ObjectInfo.Parameters[0] == 1;
|
||||
#endif
|
||||
|
||||
GameObject portalObject = GetGameObject();
|
||||
var platformController = portalObject.GetComponent<StandingPlatformController>();
|
||||
Vector3 platformPosition = platformController.transform.position;
|
||||
Vector3 platformPosition = _platformController.transform.position;
|
||||
var actorStandingPosition = new Vector3(
|
||||
platformPosition.x,
|
||||
platformController.GetPlatformHeight(),
|
||||
_platformController.GetPlatformHeight(),
|
||||
platformPosition.z);
|
||||
|
||||
var actorMovementController = ctx.PlayerActorGameObject.GetComponent<ActorMovementController>();
|
||||
@@ -117,15 +123,19 @@ namespace Pal3.Scene.SceneObjects
|
||||
Vector3 finalPosition = portalObject.transform.position;
|
||||
finalPosition.y += shouldGoUp.Value ? 10f : -10f;
|
||||
|
||||
yield return AnimationHelper.MoveTransformAsync(platformController.transform,
|
||||
yield return AnimationHelper.MoveTransformAsync(_platformController.transform,
|
||||
finalPosition,
|
||||
MOVEMENT_ANIMATION_DURATION,
|
||||
AnimationCurveType.Sine);
|
||||
|
||||
yield return null;
|
||||
|
||||
#if PAL3
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ScriptRunCommand(shouldGoUp.Value ? upperLevelScriptId : lowerLevelScriptId));
|
||||
#elif PAL3A
|
||||
ExecuteScriptIfAny();
|
||||
#endif
|
||||
|
||||
_isInteractionInProgress = false;
|
||||
}
|
||||
@@ -138,12 +148,11 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_platformController != null)
|
||||
{
|
||||
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
|
||||
_platformController.OnPlayerActorExited -= OnPlayerActorExited;
|
||||
Object.Destroy(_platformController);
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -11,6 +11,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
using Common;
|
||||
using Core.DataReader.Scn;
|
||||
using Data;
|
||||
using Renderer;
|
||||
using UnityEngine;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.Door)]
|
||||
@@ -34,9 +35,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
#if PAL3A
|
||||
if (!(ObjectInfo.Parameters[1] == 1 && ObjectInfo.Parameters[2] == 1))
|
||||
#endif
|
||||
if (!ObjectInfo.TileMapTriggerRect.IsEmpty)
|
||||
{
|
||||
// This is to prevent player from entering back to previous
|
||||
// scene when holding the stick while transferring between scenes.
|
||||
@@ -49,10 +48,26 @@ namespace Pal3.Scene.SceneObjects
|
||||
}
|
||||
|
||||
#if PAL3A
|
||||
if (ObjectInfo.IsNonBlocking == 0)
|
||||
if (ObjectInfo.Parameters[1] == 1 &&
|
||||
ObjectInfo.Parameters[2] == 1)
|
||||
{
|
||||
// Add collider to block player
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
if (ObjectInfo.SwitchState == 0)
|
||||
{
|
||||
// Add collider to block player
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
}
|
||||
else if (ObjectInfo.SwitchState == 1)
|
||||
{
|
||||
if (ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
CvdModelRenderer cvdModelRenderer = GetCvdModelRenderer();
|
||||
cvdModelRenderer.SetCurrentTime(cvdModelRenderer.GetDefaultAnimationDuration());
|
||||
}
|
||||
else if (ModelType == SceneObjectModelType.PolModel)
|
||||
{
|
||||
GetPolyModelRenderer().Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -62,18 +77,58 @@ namespace Pal3.Scene.SceneObjects
|
||||
private void OnPlayerActorEntered(object sender, Vector2Int actorTilePosition)
|
||||
{
|
||||
if (_isInteractionInProgress) return; // Prevent re-entry
|
||||
|
||||
#if PAL3
|
||||
_isInteractionInProgress = true;
|
||||
RequestForInteraction();
|
||||
#elif PAL3A
|
||||
if (ObjectInfo.Parameters[1] == 1 &&
|
||||
ObjectInfo.Parameters[2] == 1)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
_isInteractionInProgress = true;
|
||||
RequestForInteraction();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
#if PAL3A
|
||||
// Some door objects in PAL3A have parameters[1] and parameters[2] set to 1
|
||||
// which means they should deactivate themselves when interaction triggerred.
|
||||
if (ObjectInfo.Parameters[1] == 1 && ObjectInfo.Parameters[2] == 1)
|
||||
if (ObjectInfo.Parameters[1] == 1 &&
|
||||
ObjectInfo.Parameters[2] == 1)
|
||||
{
|
||||
ChangeAndSaveActivationState(false);
|
||||
if (ObjectInfo.SwitchState == 1)
|
||||
{
|
||||
_isInteractionInProgress = false;
|
||||
yield break;
|
||||
}
|
||||
|
||||
PlaySfxIfAny();
|
||||
|
||||
if (ModelType == SceneObjectModelType.PolModel)
|
||||
{
|
||||
GetPolyModelRenderer().Dispose();
|
||||
}
|
||||
else if (ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
yield return GetCvdModelRenderer().PlayOneTimeAnimationAsync(true);
|
||||
}
|
||||
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
_meshCollider = null;
|
||||
}
|
||||
|
||||
FlipAndSaveSwitchState();
|
||||
|
||||
yield return ExecuteScriptAndWaitForFinishIfAnyAsync();
|
||||
|
||||
_isInteractionInProgress = false;
|
||||
yield break;
|
||||
}
|
||||
#endif
|
||||
@@ -82,9 +137,10 @@ namespace Pal3.Scene.SceneObjects
|
||||
// parameters[0] set to 1, so we are only playing the animation if parameters[0] == 0.
|
||||
if (ObjectInfo.Parameters[0] == 0 && ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
var timeScale = 2f; // Make the animation 2X faster for better user experience
|
||||
var durationPercentage = 0.7f; // Just play 70% of the whole animation (good enough).
|
||||
yield return GetCvdModelRenderer().PlayAnimationAsync(timeScale, loopCount: 1, durationPercentage, true);
|
||||
const float timeScale = 2f; // Make the animation 2X faster for better user experience
|
||||
const float durationPercentage = 0.7f; // Just play 70% of the whole animation (good enough).
|
||||
yield return GetCvdModelRenderer().PlayAnimationAsync(timeScale,
|
||||
loopCount: 1, durationPercentage, true);
|
||||
}
|
||||
|
||||
yield return ExecuteScriptAndWaitForFinishIfAnyAsync();
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
@@ -44,7 +46,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
|
||||
yield return AnimationHelper.MoveTransformAsync(doorObject.transform, toPosition, 2f);
|
||||
|
||||
ToggleAndSaveSwitchState();
|
||||
FlipAndSaveSwitchState();
|
||||
SaveCurrentPosition();
|
||||
}
|
||||
|
||||
@@ -58,4 +60,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,8 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
@@ -103,4 +105,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,8 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
@@ -40,7 +42,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
Bounds bounds = GetMeshBounds();
|
||||
|
||||
_platformController = sceneGameObject.AddComponent<StandingPlatformController>();
|
||||
_platformController.SetBounds(bounds, ObjectInfo.LayerIndex);
|
||||
_platformController.Init(bounds, ObjectInfo.LayerIndex);
|
||||
_platformController.OnPlayerActorEntered += OnPlayerActorEntered;
|
||||
|
||||
Tilemap tilemap = ServiceLocator.Instance.Get<SceneManager>().GetCurrentScene().GetTilemap();
|
||||
@@ -70,7 +72,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
|
||||
if (!IsInteractableBasedOnTimesCount()) return;
|
||||
|
||||
ToggleAndSaveSwitchState();
|
||||
FlipAndSaveSwitchState();
|
||||
|
||||
RequestForInteraction();
|
||||
}
|
||||
@@ -123,4 +125,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,8 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using Command;
|
||||
@@ -48,4 +50,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,8 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
@@ -98,4 +100,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -10,20 +10,13 @@ namespace Pal3.Scene.SceneObjects
|
||||
using Core.DataReader.Scn;
|
||||
using Data;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.General)]
|
||||
[ScnSceneObject(ScnSceneObjectType.UnknownObj47)]
|
||||
[ScnSceneObject(ScnSceneObjectType.UnknownObj48)]
|
||||
[ScnSceneObject(ScnSceneObjectType.UnknownObj49)]
|
||||
[ScnSceneObject(ScnSceneObjectType.UnknownObj51)]
|
||||
[ScnSceneObject(ScnSceneObjectType.UnknownObj52)]
|
||||
[ScnSceneObject(ScnSceneObjectType.UnknownObj53)]
|
||||
[ScnSceneObject(ScnSceneObjectType.UnknownObj54)]
|
||||
[ScnSceneObject(ScnSceneObjectType.UnknownObj55)]
|
||||
[ScnSceneObject(ScnSceneObjectType.UnknownObj56)]
|
||||
[ScnSceneObject(ScnSceneObjectType.UnknownObj59)]
|
||||
public sealed class GeneralSceneObject : SceneObject
|
||||
{
|
||||
private SceneObjectMeshCollider _meshCollider;
|
||||
|
||||
public GeneralSceneObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
@@ -35,41 +28,61 @@ namespace Pal3.Scene.SceneObjects
|
||||
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
if (ObjectInfo.Type == ScnSceneObjectType.General)
|
||||
// Don't cast shadow on the map entrance/exit indicator.
|
||||
// Those indicators are general objects which have Info.Parameters[0] set to 1
|
||||
if (ObjectInfo.Parameters[0] == 1)
|
||||
{
|
||||
// Don't cast shadow on the map entrance/exit indicator.
|
||||
// Those indicators are general objects which have Info.Parameters[0] set to 1
|
||||
if (ObjectInfo.Parameters[0] == 1)
|
||||
foreach (MeshRenderer meshRenderer in sceneGameObject.GetComponentsInChildren<MeshRenderer>())
|
||||
{
|
||||
foreach (MeshRenderer meshRenderer in sceneGameObject.GetComponentsInChildren<MeshRenderer>())
|
||||
{
|
||||
meshRenderer.receiveShadows = false;
|
||||
}
|
||||
meshRenderer.receiveShadows = false;
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
// The general object 15 in M15 2 scene should block player
|
||||
if (ObjectInfo is { Id: 15 } &&
|
||||
SceneInfo.Is("m15", "2"))
|
||||
{
|
||||
sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
}
|
||||
// All general objects (except indicators) in M22 scene should block player
|
||||
if (SceneInfo.IsCity("m22") &&
|
||||
ObjectInfo.Parameters[0] == 0)
|
||||
{
|
||||
sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
}
|
||||
// All general objects (except indicators) in M24 scene should block player
|
||||
if (SceneInfo.IsCity("m24") &&
|
||||
ObjectInfo.Parameters[0] == 0)
|
||||
{
|
||||
sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
// The general object 15 in M15-2 scene should block player
|
||||
if (ObjectInfo is { Id: 15 } &&
|
||||
SceneInfo.Is("m15", "2"))
|
||||
{
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
}
|
||||
// All general objects (except indicators) in M22 scene should block player
|
||||
if (SceneInfo.IsCity("m22") &&
|
||||
ObjectInfo.Parameters[0] == 0)
|
||||
{
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
}
|
||||
// All general objects (except indicators) in M24 scene should block player
|
||||
if (SceneInfo.IsCity("m24") &&
|
||||
ObjectInfo.Parameters[0] == 0)
|
||||
{
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
}
|
||||
#elif PAL3A
|
||||
// Object 15 in scene M12-1 should block player
|
||||
if (SceneInfo.Is("m12", "1") && ObjectInfo.Id == 15)
|
||||
{
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
_meshCollider.Init(new Vector3(2.5f, 0f, 0f));
|
||||
}
|
||||
// Object 11 in scene M18-4 should block player
|
||||
if (SceneInfo.Is("m18", "4") && ObjectInfo.Id == 11)
|
||||
{
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
_meshCollider.Init(new Vector3(1f, 0f, 1f));
|
||||
}
|
||||
#endif
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
@@ -47,7 +49,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
};
|
||||
|
||||
_platformController = sceneGameObject.AddComponent<StandingPlatformController>();
|
||||
_platformController.SetBounds(bounds, ObjectInfo.LayerIndex);
|
||||
_platformController.Init(bounds, ObjectInfo.LayerIndex);
|
||||
_platformController.OnPlayerActorEntered += OnPlayerActorEntered;
|
||||
|
||||
// Set to final position if it is already activated
|
||||
@@ -68,7 +70,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
// Gravity switch can only be activated once, but there is one in PAL3 M24-3
|
||||
// scene that can be activated multiple times, we should fix it here.
|
||||
if (ObjectInfo.Times == 0xFF) ObjectInfo.Times = 1;
|
||||
if (ObjectInfo.Times == INFINITE_TIMES_COUNT) ObjectInfo.Times = 1;
|
||||
|
||||
if (!IsInteractableBasedOnTimesCount()) return;
|
||||
RequestForInteraction();
|
||||
@@ -121,4 +123,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,8 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System;
|
||||
@@ -81,7 +83,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new CameraFreeCommand(0));
|
||||
new CameraFollowPlayerCommand(0));
|
||||
RequestForInteraction();
|
||||
}
|
||||
|
||||
@@ -105,7 +107,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
ObjectInfo.Parameters[0],
|
||||
ObjectInfo.Parameters[1]));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new CameraFreeCommand(1));
|
||||
new CameraFollowPlayerCommand(1));
|
||||
|
||||
_isDuringInteraction = false;
|
||||
}
|
||||
@@ -151,7 +153,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
};
|
||||
|
||||
_triggerController = gameObject.AddComponent<BoundsTriggerController>();
|
||||
_triggerController.SetupCollider(bounds, true);
|
||||
_triggerController.SetBounds(bounds, true);
|
||||
_triggerController.OnPlayerActorEntered += OnPlayerActorEntered;
|
||||
|
||||
// Set initial position
|
||||
@@ -226,4 +228,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -18,7 +18,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
[ScnSceneObject(ScnSceneObjectType.InvestigationTrigger)]
|
||||
public sealed class InvestigationTriggerObject : SceneObject
|
||||
{
|
||||
private const float MAX_INTERACTION_DISTANCE = 5f;
|
||||
private const float MAX_INTERACTION_DISTANCE = 4f;
|
||||
|
||||
public InvestigationTriggerObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
@@ -45,7 +45,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
if (!IsInteractableBasedOnTimesCount()) yield break;
|
||||
|
||||
if (ctx.InitObjectId == ObjectInfo.Id)
|
||||
if (ctx.StartedByPlayer && ctx.InitObjectId == ObjectInfo.Id)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID));
|
||||
|
||||
@@ -13,7 +13,9 @@ namespace Pal3.Scene.SceneObjects
|
||||
using Core.Animation;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.GameBox;
|
||||
using Core.Services;
|
||||
using Data;
|
||||
using State;
|
||||
using UnityEngine;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.LiftingPlatform)]
|
||||
@@ -22,6 +24,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
private const float LIFTING_ANIMATION_DURATION = 2.5f;
|
||||
|
||||
private StandingPlatformController _platformController;
|
||||
private SceneObjectMeshCollider _meshCollider;
|
||||
|
||||
public LiftingPlatformObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
@@ -33,6 +36,24 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (Activated) return GetGameObject();
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
#if PAL3A
|
||||
if (!string.IsNullOrEmpty(ObjectInfo.DependentSceneName))
|
||||
{
|
||||
var sceneStateManager = ServiceLocator.Instance.Get<SceneStateManager>();
|
||||
if (sceneStateManager.TryGetSceneObjectStateOverride(
|
||||
SceneInfo.CityName,
|
||||
ObjectInfo.DependentSceneName,
|
||||
ObjectInfo.DependentObjectId,
|
||||
out SceneObjectStateOverride stateOverride))
|
||||
{
|
||||
if (stateOverride.SwitchState == 1)
|
||||
{
|
||||
ObjectInfo.SwitchState = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Set to final position if the platform is already activated
|
||||
if (ObjectInfo.SwitchState == 1)
|
||||
{
|
||||
@@ -44,24 +65,28 @@ namespace Pal3.Scene.SceneObjects
|
||||
}
|
||||
|
||||
Bounds bounds = GetMeshBounds();
|
||||
|
||||
// Some tweaks to the bounds to make sure actor won't stuck
|
||||
// near the edge of the platform
|
||||
Vector3 tweakedBoundsSize = bounds.size;
|
||||
tweakedBoundsSize.x += 0.6f;
|
||||
tweakedBoundsSize.y += 0.3f;
|
||||
var yOffset = -0.1f;
|
||||
tweakedBoundsSize.z += 0.6f;
|
||||
bounds.size = tweakedBoundsSize;
|
||||
bounds.size += new Vector3(0.6f, 0.2f, 0.6f);
|
||||
|
||||
_platformController = sceneGameObject.AddComponent<StandingPlatformController>();
|
||||
_platformController.SetBounds(bounds, ObjectInfo.LayerIndex, yOffset);
|
||||
_platformController.Init(bounds, ObjectInfo.LayerIndex);
|
||||
|
||||
#if PAL3A
|
||||
if (bounds.size.y > 1f)
|
||||
{
|
||||
// Add a mesh collider to block the player from walking into the object
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
_meshCollider.Init(new Vector3(-0.3f, -0.8f, -0.3f));
|
||||
}
|
||||
#endif
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
#if PAL3
|
||||
// Fix a bug in m22-4 where the script can interact with the platform
|
||||
// even though the platform is already activated with correct height.
|
||||
// This is to prevent the unwanted interaction triggered by the script
|
||||
@@ -70,6 +95,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!IsInteractableBasedOnTimesCount()) yield break;
|
||||
|
||||
@@ -88,7 +114,8 @@ namespace Pal3.Scene.SceneObjects
|
||||
ObjectInfo.GameBoxPosition.y);
|
||||
var yOffset = finalYPosition - position.y;
|
||||
|
||||
ToggleAndSaveSwitchState();
|
||||
FlipAndSaveSwitchState();
|
||||
|
||||
PlaySfxIfAny();
|
||||
|
||||
var hasObjectOnPlatform = false;
|
||||
@@ -106,8 +133,8 @@ namespace Pal3.Scene.SceneObjects
|
||||
}
|
||||
}
|
||||
|
||||
yield return AnimationHelper.EnumerateValueAsync(0f, yOffset, LIFTING_ANIMATION_DURATION, AnimationCurveType.Sine,
|
||||
offset =>
|
||||
yield return AnimationHelper.EnumerateValueAsync(0f, yOffset, LIFTING_ANIMATION_DURATION,
|
||||
AnimationCurveType.Sine, offset =>
|
||||
{
|
||||
liftingMechanismGameObject.transform.position =
|
||||
new Vector3(position.x, position.y + offset, position.z);
|
||||
@@ -143,6 +170,11 @@ namespace Pal3.Scene.SceneObjects
|
||||
Object.Destroy(_platformController);
|
||||
}
|
||||
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
[ScnSceneObject(ScnSceneObjectType.MovableCarrier)]
|
||||
public sealed class MovableCarrierObject : SceneObject
|
||||
{
|
||||
private float MOVE_SPEED = 3.5f;
|
||||
private float MOVE_SPEED = 5f;
|
||||
|
||||
private StandingPlatformController _platformController;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
Bounds bounds = GetMeshBounds();
|
||||
bounds.size *= 1.35f; // Make it a little bigger
|
||||
bounds.size += new Vector3(0.6f, 0.2f, 0.6f); // Extend the bounds a little bit
|
||||
|
||||
#if PAL3
|
||||
if (SceneInfo.Is("m23", "5") &&
|
||||
@@ -52,10 +52,21 @@ namespace Pal3.Scene.SceneObjects
|
||||
size = new Vector3(8.5f, 13.5f, 8.5f),
|
||||
};
|
||||
}
|
||||
#elif PAL3A
|
||||
if (SceneInfo.Is("m10", "2") &&
|
||||
(ObjectInfo.Name.Equals("_f.pol", StringComparison.OrdinalIgnoreCase) ||
|
||||
ObjectInfo.Name.Equals("_g.pol", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
bounds = new Bounds
|
||||
{
|
||||
center = new Vector3(0f, -0.3f, 0f),
|
||||
size = new Vector3(6f, 0.7f, 6f),
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
_platformController = sceneGameObject.AddComponent<StandingPlatformController>();
|
||||
_platformController.SetBounds(bounds, ObjectInfo.LayerIndex);
|
||||
_platformController.Init(bounds, ObjectInfo.LayerIndex);
|
||||
_platformController.OnPlayerActorEntered += OnPlayerActorEntered;
|
||||
|
||||
return sceneGameObject;
|
||||
@@ -64,8 +75,14 @@ namespace Pal3.Scene.SceneObjects
|
||||
private void OnPlayerActorEntered(object sender, GameObject playerActorGameObject)
|
||||
{
|
||||
if (_isInteractionInProgress) return;
|
||||
_isInteractionInProgress = true;
|
||||
RequestForInteraction();
|
||||
|
||||
// Make sure player is at the same height as the platform
|
||||
if (Mathf.Abs(playerActorGameObject.transform.position.y -
|
||||
_platformController.GetPlatformHeight()) <= 0.5f)
|
||||
{
|
||||
_isInteractionInProgress = true;
|
||||
RequestForInteraction();
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3A
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
using Common;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.Services;
|
||||
using Data;
|
||||
using UnityEngine;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.MushroomBridge)]
|
||||
public sealed class MushroomBridgeObject : SceneObject
|
||||
{
|
||||
private const float ROTATION_DEGREES_PER_SECOND = 45f;
|
||||
|
||||
private StandingPlatformController _platformController;
|
||||
|
||||
private readonly Tilemap _tilemap;
|
||||
|
||||
public MushroomBridgeObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
_tilemap = ServiceLocator.Instance.Get<SceneManager>().GetCurrentScene().GetTilemap();
|
||||
}
|
||||
|
||||
public override GameObject Activate(GameResourceProvider resourceProvider, Color tintColor)
|
||||
{
|
||||
if (Activated) return GetGameObject();
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
Bounds bounds = new()
|
||||
{
|
||||
center = new Vector3(0f, -0.5f, 0f),
|
||||
size = new Vector3(9f, 1f, 4f),
|
||||
};
|
||||
|
||||
// Add a standing platform controller to make sure the player can walk on the bridge
|
||||
_platformController = sceneGameObject.AddComponent<StandingPlatformController>();
|
||||
_platformController.Init(bounds, ObjectInfo.LayerIndex);
|
||||
|
||||
if (ObjectInfo.SwitchState == 1)
|
||||
{
|
||||
Vector2Int centerTile = new Vector2Int(ObjectInfo.Parameters[0], ObjectInfo.Parameters[1]);
|
||||
Vector3 centerPoint = _tilemap.GetWorldPosition(centerTile, ObjectInfo.LayerIndex);
|
||||
float toDegrees = ObjectInfo.Parameters[2];
|
||||
sceneGameObject.transform.RotateAround(centerPoint, Vector3.up, toDegrees);
|
||||
}
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
FlipAndSaveSwitchState();
|
||||
|
||||
PlaySfxIfAny();
|
||||
|
||||
Transform transform = GetGameObject().transform;
|
||||
Vector2Int centerTile = new Vector2Int(ObjectInfo.Parameters[0], ObjectInfo.Parameters[1]);
|
||||
Vector3 centerPoint = ctx.CurrentScene.GetTilemap().GetWorldPosition(centerTile, ObjectInfo.LayerIndex);
|
||||
|
||||
float toDegrees = ObjectInfo.Parameters[2];
|
||||
float currentDegrees = 0f;
|
||||
|
||||
float direction = ObjectInfo.SwitchState == 1 ? Mathf.Sign(toDegrees) : -Mathf.Sign(toDegrees);
|
||||
toDegrees = Mathf.Abs(toDegrees);
|
||||
|
||||
while (currentDegrees < toDegrees)
|
||||
{
|
||||
float deltaDegrees = ROTATION_DEGREES_PER_SECOND * Time.deltaTime;
|
||||
|
||||
if (deltaDegrees + currentDegrees > toDegrees)
|
||||
{
|
||||
deltaDegrees = toDegrees - currentDegrees;
|
||||
}
|
||||
|
||||
transform.RotateAround(centerPoint, Vector3.up, deltaDegrees * direction);
|
||||
|
||||
currentDegrees += deltaDegrees;
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
if (_platformController != null)
|
||||
{
|
||||
Object.Destroy(_platformController);
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 368cfdc7ea9f4f81b2e1c92d62393ef0
|
||||
timeCreated: 1678771055
|
||||
@@ -0,0 +1,77 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3A
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Common;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.Services;
|
||||
using MetaData;
|
||||
using Player;
|
||||
using UnityEngine;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.PaperweightDesk)]
|
||||
public sealed class PaperweightDeskObject : SceneObject
|
||||
{
|
||||
private const float MAX_INTERACTION_DISTANCE = 2f;
|
||||
|
||||
private readonly Dictionary<int, int> _deskIdToRequiredItemIdMap = new()
|
||||
{
|
||||
[20] = 6657,
|
||||
[21] = 6659,
|
||||
[22] = 6658,
|
||||
};
|
||||
|
||||
private readonly InventoryManager _inventoryManager;
|
||||
|
||||
public PaperweightDeskObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
_inventoryManager = ServiceLocator.Instance.Get<InventoryManager>();
|
||||
}
|
||||
|
||||
public override bool IsDirectlyInteractable(float distance)
|
||||
{
|
||||
return Activated &&
|
||||
distance < MAX_INTERACTION_DISTANCE &&
|
||||
ObjectInfo.Times > 0;
|
||||
}
|
||||
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
if (!_deskIdToRequiredItemIdMap.ContainsKey(ObjectInfo.Id)) yield break;
|
||||
|
||||
if (_inventoryManager.HaveItem(_deskIdToRequiredItemIdMap[ObjectInfo.Id]))
|
||||
{
|
||||
if (!IsInteractableBasedOnTimesCount()) yield break;
|
||||
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new PlayerActorLookAtSceneObjectCommand(ObjectInfo.Id));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorPerformActionCommand(ActorConstants.PlayerActorVirtualID,
|
||||
ActorConstants.ActionNames[ActorActionType.Check], 1));
|
||||
|
||||
yield return new WaitForSeconds(0.8f); // Wait for actor animation to finish
|
||||
|
||||
yield return ActivateOrInteractWithObjectIfAnyAsync(ctx, ObjectInfo.LinkedObjectId);
|
||||
}
|
||||
else
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new UIDisplayNoteCommand("还没有找到合适的东西"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56ec0e4eac5b4fab84e27b28659d8c0c
|
||||
timeCreated: 1678822224
|
||||
@@ -0,0 +1,23 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3A
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using Common;
|
||||
using Core.DataReader.Scn;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.Paperweight)]
|
||||
public sealed class PaperweightObject : SceneObject
|
||||
{
|
||||
public PaperweightObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25114722100241f6b2459d71b046491b
|
||||
timeCreated: 1678822234
|
||||
@@ -43,6 +43,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
|
||||
Bounds bounds = GetMeshBounds();
|
||||
|
||||
#if PAL3
|
||||
if (SceneInfo.IsCity("m11") &&
|
||||
ObjectInfo.Name.Equals("_h1.pol", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -61,9 +62,10 @@ namespace Pal3.Scene.SceneObjects
|
||||
size = new Vector3(3.5f, 0.5f, 6f),
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
_platformController = sceneGameObject.AddComponent<StandingPlatformController>();
|
||||
_platformController.SetBounds(bounds, ObjectInfo.LayerIndex);
|
||||
_platformController.Init(bounds, ObjectInfo.LayerIndex);
|
||||
_platformController.OnPlayerActorEntered += OnPlayerActorEntered;
|
||||
|
||||
// Set to final position if it is already activated
|
||||
@@ -116,6 +118,10 @@ namespace Pal3.Scene.SceneObjects
|
||||
|
||||
yield return ActivateOrInteractWithObjectIfAnyAsync(ctx, ObjectInfo.LinkedObjectId);
|
||||
|
||||
#if PAL3A
|
||||
FlipAndSaveSwitchState();
|
||||
#endif
|
||||
|
||||
_isInteractionInProgress = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
ObjectInfo.Parameters[0],
|
||||
ObjectInfo.Parameters[1]));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new CameraFreeCommand(1));
|
||||
new CameraFocusOnSceneObjectCommand(1));
|
||||
#elif PAL3A
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID));
|
||||
@@ -104,7 +104,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorSetWorldPositionCommand(-1, worldPosition.x, worldPosition.z));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new CameraFreeCommand(1));
|
||||
new CameraFollowPlayerCommand(1));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System;
|
||||
@@ -56,7 +58,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
Bounds meshBounds = GetMeshBounds();
|
||||
|
||||
_triggerController = sceneGameObject.AddComponent<BoundsTriggerController>();
|
||||
_triggerController.SetupCollider(meshBounds, false);
|
||||
_triggerController.SetBounds(meshBounds, false);
|
||||
_triggerController.OnPlayerActorEntered += OnPlayerActorEntered;
|
||||
|
||||
// For pushable object player can stand on
|
||||
@@ -66,7 +68,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
Bounds platformBounds = meshBounds;
|
||||
platformBounds.size *= 1.5f;
|
||||
_standingPlatformController = sceneGameObject.AddComponent<StandingPlatformController>();
|
||||
_standingPlatformController.SetBounds(platformBounds, ObjectInfo.LayerIndex, -0.3f);
|
||||
_standingPlatformController.Init(platformBounds, ObjectInfo.LayerIndex, -0.3f);
|
||||
}
|
||||
|
||||
return sceneGameObject;
|
||||
@@ -372,4 +374,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -18,7 +18,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
[ScnSceneObject(ScnSceneObjectType.RareChest)]
|
||||
public sealed class RareChestObject : SceneObject
|
||||
{
|
||||
private const float MAX_INTERACTION_DISTANCE = 4f;
|
||||
private const float MAX_INTERACTION_DISTANCE = 3f;
|
||||
|
||||
private SceneObjectMeshCollider _meshCollider;
|
||||
|
||||
@@ -50,6 +50,8 @@ namespace Pal3.Scene.SceneObjects
|
||||
new ActorPerformActionCommand(ActorConstants.PlayerActorVirtualID,
|
||||
ActorConstants.ActionNames[ActorActionType.Check], 1));
|
||||
|
||||
PlaySfx("wg011");
|
||||
|
||||
if (ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
yield return GetCvdModelRenderer().PlayOneTimeAnimationAsync(true);
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
using Common;
|
||||
using Core.Animation;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.GameBox;
|
||||
using Data;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.RetractableBlocker)]
|
||||
public sealed class RetractableBlockerObject : SceneObject
|
||||
{
|
||||
private SceneObjectMeshCollider _meshCollider;
|
||||
|
||||
public RetractableBlockerObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public override GameObject Activate(GameResourceProvider resourceProvider, Color tintColor)
|
||||
{
|
||||
if (Activated) return GetGameObject();
|
||||
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
// Add mesh collider to block player
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
PlaySfxIfAny();
|
||||
|
||||
GameObject blockerObject = GetGameObject();
|
||||
Vector3 currentPosition = blockerObject.transform.position;
|
||||
var zOffset = GameBoxInterpreter.ToUnityDistance(ObjectInfo.Parameters[2]);
|
||||
Vector3 toPosition = currentPosition + blockerObject.transform.forward * -zOffset;
|
||||
|
||||
yield return AnimationHelper.MoveTransformAsync(blockerObject.transform, toPosition, 1.5f);
|
||||
|
||||
SaveCurrentPosition();
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 012baa2013ed4ca3948d453c53f8da34
|
||||
timeCreated: 1678593607
|
||||
@@ -0,0 +1,145 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3A
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
using Common;
|
||||
using Core.Animation;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.GameBox;
|
||||
using Data;
|
||||
using Renderer;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.RoadElevatorOrBlocker)]
|
||||
public sealed class RoadElevatorOrBlockerObject : SceneObject
|
||||
{
|
||||
private StandingPlatformController _platformController;
|
||||
private SceneObjectMeshCollider _meshCollider;
|
||||
|
||||
public RoadElevatorOrBlockerObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public override GameObject Activate(GameResourceProvider resourceProvider, Color tintColor)
|
||||
{
|
||||
if (Activated) return GetGameObject();
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
Bounds bounds = GetMeshBounds();
|
||||
bounds.size += new Vector3(0.6f, 0.2f, 0.6f); // Extend the bounds a little bit
|
||||
|
||||
// This is a blocker object
|
||||
if (ObjectInfo.Parameters[4] == 1 &&
|
||||
ObjectInfo.Parameters[5] == 1)
|
||||
{
|
||||
if (ObjectInfo.SwitchState == 1 && ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
CvdModelRenderer cvdModelRenderer = GetCvdModelRenderer();
|
||||
cvdModelRenderer.SetCurrentTime(cvdModelRenderer.GetDefaultAnimationDuration());
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
}
|
||||
}
|
||||
else // This is a road elevator object
|
||||
{
|
||||
// Add a standing platform controller so that the player can stand on the floor
|
||||
_platformController = sceneGameObject.AddComponent<StandingPlatformController>();
|
||||
_platformController.Init(bounds, ObjectInfo.LayerIndex);
|
||||
|
||||
// Add a mesh collider to block the player from walking into the object
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
_meshCollider.Init(new Vector3(-0.3f, -0.8f, -0.3f));
|
||||
}
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
PlaySfxIfAny();
|
||||
|
||||
GameObject floorObject = GetGameObject();
|
||||
|
||||
// This is a blocker object
|
||||
if (ObjectInfo.Parameters[4] == 1 &&
|
||||
ObjectInfo.Parameters[5] == 1)
|
||||
{
|
||||
FlipAndSaveSwitchState();
|
||||
|
||||
yield return GetCvdModelRenderer().PlayOneTimeAnimationAsync(true);
|
||||
|
||||
if (ObjectInfo.Parameters[2] != 0)
|
||||
{
|
||||
Transform transform = floorObject.transform;
|
||||
float yOffset = GameBoxInterpreter.ToUnityDistance(ObjectInfo.Parameters[2]);
|
||||
Vector3 finalPosition = transform.position + new Vector3(0f, -yOffset, 0f);
|
||||
yield return AnimationHelper.MoveTransformAsync(floorObject.transform, finalPosition, 0.5f);
|
||||
SaveCurrentPosition();
|
||||
}
|
||||
|
||||
if (_meshCollider == null)
|
||||
{
|
||||
_meshCollider = floorObject.AddComponent<SceneObjectMeshCollider>();
|
||||
}
|
||||
}
|
||||
else // This is an elevator floor object
|
||||
{
|
||||
Vector3 currentPosition = floorObject.transform.position;
|
||||
|
||||
float lowerYPosition = GameBoxInterpreter.ToUnityYPosition(
|
||||
ObjectInfo.Parameters[0] * ObjectInfo.Parameters[4]);
|
||||
float upperYPosition = GameBoxInterpreter.ToUnityYPosition(
|
||||
ObjectInfo.Parameters[2] * ObjectInfo.Parameters[5]);
|
||||
|
||||
if (SceneInfo.Is("m05", "3"))
|
||||
{
|
||||
lowerYPosition = 0f;
|
||||
}
|
||||
|
||||
float finalYPosition = lowerYPosition;
|
||||
|
||||
if (Mathf.Abs(currentPosition.y - lowerYPosition) < Mathf.Abs(currentPosition.y - upperYPosition))
|
||||
{
|
||||
finalYPosition = upperYPosition;
|
||||
}
|
||||
|
||||
Vector3 toPosition = new Vector3(currentPosition.x, finalYPosition, currentPosition.z);
|
||||
|
||||
var duration = 2f;
|
||||
|
||||
if (SceneInfo.Is("m06", "2"))
|
||||
{
|
||||
duration = 0.3f;
|
||||
}
|
||||
|
||||
yield return AnimationHelper.MoveTransformAsync(floorObject.transform, toPosition, duration);
|
||||
|
||||
SaveCurrentPosition();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
if (_platformController != null)
|
||||
{
|
||||
Object.Destroy(_platformController);
|
||||
}
|
||||
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 494fbdcf7d874bd5aafedcec5c7933aa
|
||||
timeCreated: 1678334260
|
||||
@@ -3,6 +3,8 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System;
|
||||
@@ -56,7 +58,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
}
|
||||
|
||||
_platformController = sceneGameObject.AddComponent<StandingPlatformController>();
|
||||
_platformController.SetBounds(bounds, ObjectInfo.LayerIndex);
|
||||
_platformController.Init(bounds, ObjectInfo.LayerIndex);
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
@@ -79,7 +81,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
yield return AnimationHelper.RotateTransformAsync(bridgeObject.transform,
|
||||
Quaternion.Euler(targetRotation), ROTATION_ANIMATION_DURATION, AnimationCurveType.Sine);
|
||||
|
||||
SaveYRotation();
|
||||
SaveCurrentYRotation();
|
||||
|
||||
ResetCamera();
|
||||
}
|
||||
@@ -94,4 +96,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,101 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3A
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
using Common;
|
||||
using Core.Animation;
|
||||
using Core.DataLoader;
|
||||
using Core.DataReader.Pol;
|
||||
using Core.DataReader.Scn;
|
||||
using Data;
|
||||
using Renderer;
|
||||
using UnityEngine;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.RotatingWall)]
|
||||
public sealed class RotatingWallObject : SceneObject
|
||||
{
|
||||
private SceneObjectMeshCollider _meshCollider;
|
||||
|
||||
private GameObject _subObjectGameObject;
|
||||
private SceneObjectMeshCollider _subObjectMeshCollider;
|
||||
|
||||
public RotatingWallObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public override GameObject Activate(GameResourceProvider resourceProvider, Color tintColor)
|
||||
{
|
||||
if (Activated) return GetGameObject();
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
// Add mesh collider to block player
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
_meshCollider.Init(new Vector3(-1f, 0f, 0f));
|
||||
|
||||
// Add sub-component to the main object.
|
||||
if (ModelFilePath.EndsWith("1.pol"))
|
||||
{
|
||||
_subObjectGameObject = new GameObject($"Object_{ObjectInfo.Id}_{ObjectInfo.Type}_SubObject");
|
||||
|
||||
var subObjectModelPath = ModelFilePath.Replace("1.pol", "2.pol");
|
||||
(PolFile PolFile, ITextureResourceProvider TextureProvider) poly = resourceProvider.GetPol(subObjectModelPath);
|
||||
var subObjectModelRenderer = _subObjectGameObject.AddComponent<PolyModelRenderer>();
|
||||
subObjectModelRenderer.Render(poly.PolFile,
|
||||
resourceProvider.GetMaterialFactory(),
|
||||
poly.TextureProvider,
|
||||
tintColor);
|
||||
|
||||
// Sub-object should block player as well, so let's add mesh collider to it
|
||||
_subObjectMeshCollider = _subObjectGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
_subObjectMeshCollider.Init(new Vector3(0f, 0f, -1f));
|
||||
|
||||
_subObjectGameObject.transform.SetParent(sceneGameObject.transform, false);
|
||||
}
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
PlaySfxIfAny();
|
||||
|
||||
Transform objectTransform = GetGameObject().transform;
|
||||
Quaternion rotation = objectTransform.rotation;
|
||||
Quaternion targetRotation = rotation * Quaternion.Euler(0, -ObjectInfo.Parameters[1], 0);
|
||||
|
||||
yield return AnimationHelper.RotateTransformAsync(objectTransform,
|
||||
targetRotation, 2.2f, AnimationCurveType.Sine);
|
||||
|
||||
SaveCurrentYRotation();
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
}
|
||||
|
||||
if (_subObjectMeshCollider != null)
|
||||
{
|
||||
Object.Destroy(_subObjectMeshCollider);
|
||||
}
|
||||
|
||||
if (_subObjectGameObject != null)
|
||||
{
|
||||
Object.Destroy(_subObjectGameObject);
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40bcd1decae943e9aa9aed5f2ff5b076
|
||||
timeCreated: 1678516953
|
||||
@@ -37,10 +37,14 @@ namespace Pal3.Scene.SceneObjects
|
||||
public int InitObjectId;
|
||||
public Scene CurrentScene;
|
||||
public GameObject PlayerActorGameObject;
|
||||
public bool StartedByPlayer;
|
||||
}
|
||||
|
||||
public abstract class SceneObject
|
||||
{
|
||||
internal const ushort INVALID_SCENE_OBJECT_ID = 0xFFFF;
|
||||
internal const byte INFINITE_TIMES_COUNT = 0xFF;
|
||||
|
||||
public ScnObjectInfo ObjectInfo;
|
||||
public ScnSceneInfo SceneInfo;
|
||||
public GraphicsEffect GraphicsEffect { get; }
|
||||
@@ -134,24 +138,10 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
(CvdFile CvdFile, ITextureResourceProvider TextureProvider) cvd = resourceProvider.GetCvd(ModelFilePath);
|
||||
_cvdModelRenderer = _sceneObjectGameObject.AddComponent<CvdModelRenderer>();
|
||||
|
||||
var initTime = 0f;
|
||||
|
||||
if (ObjectInfo.Type is ScnSceneObjectType.Switch
|
||||
#if PAL3
|
||||
or ScnSceneObjectType.Collidable
|
||||
#endif
|
||||
or ScnSceneObjectType.Shakeable
|
||||
&& ObjectInfo.SwitchState == 1)
|
||||
{
|
||||
initTime = cvd.CvdFile.AnimationDuration;
|
||||
}
|
||||
|
||||
_cvdModelRenderer.Init(cvd.CvdFile,
|
||||
resourceProvider.GetMaterialFactory(),
|
||||
cvd.TextureProvider,
|
||||
tintColor,
|
||||
initTime);
|
||||
tintColor);
|
||||
|
||||
if (ObjectInfo.Type == ScnSceneObjectType.General)
|
||||
{
|
||||
@@ -298,7 +288,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
switch (ObjectInfo.Times)
|
||||
{
|
||||
case 0xFF:
|
||||
case INFINITE_TIMES_COUNT:
|
||||
return true;
|
||||
case <= 0:
|
||||
return false;
|
||||
@@ -348,7 +338,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
// so no need to dispatch a SceneSaveGlobalObjectActivationStateCommand here
|
||||
}
|
||||
|
||||
internal void ToggleAndSaveSwitchState()
|
||||
internal void FlipAndSaveSwitchState()
|
||||
{
|
||||
ObjectInfo.SwitchState = ObjectInfo.SwitchState == 0 ? (byte) 1 : (byte) 0;
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
@@ -360,7 +350,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
|
||||
internal IEnumerator ActivateOrInteractWithObjectIfAnyAsync(InteractionContext ctx, ushort objectId)
|
||||
{
|
||||
if (objectId == 0xFFFF) yield break;
|
||||
if (objectId == INVALID_SCENE_OBJECT_ID) yield break;
|
||||
|
||||
var allActivatedSceneObjects = ctx.CurrentScene.GetAllActivatedSceneObjects();
|
||||
|
||||
@@ -368,20 +358,28 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new SceneActivateObjectCommand(objectId, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return ctx.CurrentScene.GetSceneObject(objectId).InteractAsync(ctx);
|
||||
}
|
||||
|
||||
#if PAL3A
|
||||
// PAL3A has additional activation logic for chained objects
|
||||
// When all objects linked to a child object are activated, the child object will be activated
|
||||
ushort nextLinkedObjectId = ctx.CurrentScene.GetSceneObject(objectId).ObjectInfo.LinkedObjectId;
|
||||
if (nextLinkedObjectId != 0xFFFF)
|
||||
#if PAL3A
|
||||
// PAL3A has additional activation logic for chained objects
|
||||
// When all objects linked to a child object are activated, the child object will be activated
|
||||
SceneObject linkedObject = ctx.CurrentScene.GetSceneObject(objectId);
|
||||
ushort nextLinkedObjectId = linkedObject.ObjectInfo.LinkedObjectId;
|
||||
if (nextLinkedObjectId != INVALID_SCENE_OBJECT_ID)
|
||||
{
|
||||
HashSet<int> activatedObjects = ctx.CurrentScene.GetAllActivatedSceneObjects();
|
||||
if (ctx.CurrentScene.GetAllSceneObjects()
|
||||
.Where(_ => _.Value.ObjectInfo.LinkedObjectId == nextLinkedObjectId)
|
||||
.All(_ => activatedObjects.Contains(_.Key)))
|
||||
{
|
||||
HashSet<int> activatedObjects = ctx.CurrentScene.GetAllActivatedSceneObjects();
|
||||
if (ctx.CurrentScene.GetAllSceneObjects()
|
||||
.Where(_ => _.Value.ObjectInfo.LinkedObjectId == nextLinkedObjectId)
|
||||
.All(_ => activatedObjects.Contains(_.Key)))
|
||||
{
|
||||
SceneObject nextLinkedObject = ctx.CurrentScene.GetSceneObject(nextLinkedObjectId);
|
||||
SceneObject nextLinkedObject = ctx.CurrentScene.GetSceneObject(nextLinkedObjectId);
|
||||
|
||||
if (linkedObject.ObjectInfo.Type != nextLinkedObject.ObjectInfo.Type)
|
||||
{
|
||||
yield return new WaitForSeconds(1);
|
||||
ResetCamera(); // Make sure camera is looking at the player before moving
|
||||
yield return null; // Wait for one frame to make sure camera is reset
|
||||
@@ -396,13 +394,13 @@ namespace Pal3.Scene.SceneObjects
|
||||
ResetCamera(); // Reset again
|
||||
yield return null; // Wait for one frame to make sure camera is reset
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return ActivateOrInteractWithObjectIfAnyAsync(ctx, nextLinkedObjectId);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return ctx.CurrentScene.GetSceneObject(objectId).InteractAsync(ctx);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
internal void ChangeAndSaveNavLayerIndex(byte layerIndex)
|
||||
@@ -424,7 +422,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
GameBoxInterpreter.ToGameBoxPosition(_sceneObjectGameObject.transform.position)));
|
||||
}
|
||||
|
||||
internal void SaveYRotation()
|
||||
internal void SaveCurrentYRotation()
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new SceneSaveGlobalObjectYRotationCommand(SceneInfo.CityName,
|
||||
@@ -437,25 +435,25 @@ namespace Pal3.Scene.SceneObjects
|
||||
Vector3 position,
|
||||
GameObject playerActorGameObject)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new CameraFreeCommand(0));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new CameraFollowPlayerCommand(0));
|
||||
|
||||
Vector3 offset = position - playerActorGameObject.transform.position;
|
||||
Transform cameraTransform = Camera.main!.transform;
|
||||
Vector3 cameraCurrentPosition = cameraTransform.position;
|
||||
Vector3 targetPosition = cameraCurrentPosition + offset;
|
||||
yield return AnimationHelper.MoveTransformAsync(cameraTransform,
|
||||
targetPosition, 1.5f, AnimationCurveType.Sine);
|
||||
targetPosition, 2f, AnimationCurveType.Sine);
|
||||
}
|
||||
|
||||
internal void CameraFocusOnObject(int objectId)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new CameraFreeCommand(1));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new CameraFollowPlayerCommand(1));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new CameraFocusOnSceneObjectCommand(objectId));
|
||||
}
|
||||
|
||||
internal void ResetCamera()
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new CameraFreeCommand(1));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new CameraFollowPlayerCommand(1));
|
||||
}
|
||||
|
||||
internal bool IsFullyVisibleToCamera()
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3A
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
using Common;
|
||||
using Core.DataReader.Scn;
|
||||
using Data;
|
||||
using Renderer;
|
||||
using UnityEngine;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.SectorBridge)]
|
||||
public sealed class SectorBridgeObject : SceneObject
|
||||
{
|
||||
private StandingPlatformController _standingPlatformController;
|
||||
|
||||
public SectorBridgeObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public override GameObject Activate(GameResourceProvider resourceProvider, Color tintColor)
|
||||
{
|
||||
if (Activated) return GetGameObject();
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
if (ObjectInfo.SwitchState == 1)
|
||||
{
|
||||
if (ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
CvdModelRenderer cvdModelRenderer = GetCvdModelRenderer();
|
||||
cvdModelRenderer.SetCurrentTime(cvdModelRenderer.GetDefaultAnimationDuration());
|
||||
}
|
||||
|
||||
_standingPlatformController = sceneGameObject.AddComponent<StandingPlatformController>();
|
||||
_standingPlatformController.Init(GetMeshBounds(), ObjectInfo.LayerIndex);
|
||||
}
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
if (ObjectInfo.SwitchState == 1) yield break;
|
||||
|
||||
FlipAndSaveSwitchState();
|
||||
|
||||
PlaySfxIfAny();
|
||||
|
||||
if (ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
yield return GetCvdModelRenderer().PlayOneTimeAnimationAsync(true);
|
||||
}
|
||||
|
||||
_standingPlatformController = GetGameObject().AddComponent<StandingPlatformController>();
|
||||
_standingPlatformController.Init(GetMeshBounds(), ObjectInfo.LayerIndex);
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
if (_standingPlatformController != null)
|
||||
{
|
||||
Object.Destroy(_standingPlatformController);
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 825261d99aa24bf99b81c37b0a72aadf
|
||||
timeCreated: 1678774725
|
||||
@@ -3,6 +3,8 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System;
|
||||
@@ -16,12 +18,15 @@ namespace Pal3.Scene.SceneObjects
|
||||
using Data;
|
||||
using MetaData;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.SpecialSwitch)]
|
||||
public sealed class SpecialSwitchObject : SceneObject
|
||||
{
|
||||
private const float MAX_INTERACTION_DISTANCE = 4f;
|
||||
|
||||
private SceneObjectMeshCollider _meshCollider;
|
||||
|
||||
public SpecialSwitchObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
@@ -34,19 +39,18 @@ namespace Pal3.Scene.SceneObjects
|
||||
|
||||
// Add collider to block player, also make the bounds of the collider a little bit bigger
|
||||
// to make sure the player can't walk through the collider
|
||||
var boundsScale = (PlayerActorId) ObjectInfo.Parameters[0] switch
|
||||
Vector3 boundsSizeOffset = (PlayerActorId) ObjectInfo.Parameters[0] switch
|
||||
{
|
||||
#if PAL3
|
||||
PlayerActorId.JingTian => 1.5f,
|
||||
PlayerActorId.XueJian => 1.5f,
|
||||
PlayerActorId.LongKui => 1.2f,
|
||||
PlayerActorId.ZiXuan => 1.2f,
|
||||
PlayerActorId.ChangQing => 1.7f,
|
||||
#endif
|
||||
_ => 1f
|
||||
PlayerActorId.JingTian => new Vector3(1.5f, 0f, 1.5f),
|
||||
PlayerActorId.XueJian => new Vector3(1f, 0f, 1f),
|
||||
PlayerActorId.LongKui => new Vector3(2.5f, 0f, 2.5f),
|
||||
PlayerActorId.ZiXuan => new Vector3(0.8f, 0f, 0.8f),
|
||||
PlayerActorId.ChangQing => new Vector3(2.3f, 0f, 2.3f),
|
||||
_ => Vector3.one
|
||||
};
|
||||
|
||||
sceneGameObject.AddComponent<SceneObjectMeshCollider>().SetBoundsScale(boundsScale);
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
_meshCollider.Init(boundsSizeOffset);
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
@@ -81,7 +85,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
|
||||
yield return new WaitForSeconds(1.2f); // Wait for actor animation to finish
|
||||
|
||||
#if PAL3
|
||||
var sfxName = actorId switch
|
||||
{
|
||||
PlayerActorId.JingTian => "we026",
|
||||
@@ -96,7 +99,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
PlaySfx(sfxName);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
@@ -105,5 +107,17 @@ namespace Pal3.Scene.SceneObjects
|
||||
|
||||
ChangeAndSaveActivationState(false);
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -82,7 +82,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
}
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
private void LateUpdate()
|
||||
{
|
||||
switch (_parameters[2])
|
||||
{
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
@@ -79,7 +81,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
};
|
||||
|
||||
_platformController = GetGameObject().GetOrAddComponent<StandingPlatformController>();
|
||||
_platformController.SetBounds(bounds, ObjectInfo.LayerIndex);
|
||||
_platformController.Init(bounds, ObjectInfo.LayerIndex);
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
@@ -92,4 +94,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,9 +3,10 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using Command;
|
||||
@@ -16,8 +17,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
using Core.DataReader.Cpk;
|
||||
using Core.DataReader.Cvd;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.GameBox;
|
||||
using Core.Services;
|
||||
using Data;
|
||||
using MetaData;
|
||||
using Renderer;
|
||||
@@ -27,16 +26,14 @@ namespace Pal3.Scene.SceneObjects
|
||||
[ScnSceneObject(ScnSceneObjectType.Switch)]
|
||||
public sealed class SwitchObject : SceneObject
|
||||
{
|
||||
private const float MAX_INTERACTION_DISTANCE = 4f;
|
||||
private const float MAX_INTERACTION_DISTANCE = 3f;
|
||||
|
||||
private SceneObjectMeshCollider _meshCollider;
|
||||
|
||||
#if PAL3
|
||||
private readonly string _interactionIndicatorModelPath = FileConstants.ObjectFolderVirtualPath +
|
||||
CpkConstants.DirectorySeparator + "g03.cvd";
|
||||
private CvdModelRenderer _interactionIndicatorRenderer;
|
||||
private GameObject _interactionIndicatorGameObject;
|
||||
#endif
|
||||
|
||||
public SwitchObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
@@ -48,17 +45,11 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (Activated) return GetGameObject();
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
#if PAL3A
|
||||
// All switches in PAL3A have 0xFF as Times, which means infinite times.
|
||||
// but all switches in PAL3A can only be interacted once.
|
||||
// So we set Times to 1 here.
|
||||
// We can also disable the switch when SwitchState == 1 for PAL3A,
|
||||
// but this way is simpler.
|
||||
if (ObjectInfo.Times == 0xFF)
|
||||
if (ObjectInfo.SwitchState == 1 && ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
ObjectInfo.Times = 1;
|
||||
CvdModelRenderer cvdModelRenderer = GetCvdModelRenderer();
|
||||
cvdModelRenderer.SetCurrentTime(cvdModelRenderer.GetDefaultAnimationDuration());
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ObjectInfo.IsNonBlocking == 0)
|
||||
{
|
||||
@@ -70,7 +61,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
}
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
// Add interaction indicator when switch times is greater than 0
|
||||
// and Parameter[1] is 0 (1 means the switch is not directly interactable)
|
||||
if (ObjectInfo.Times > 0 && ObjectInfo.Parameters[1] == 0)
|
||||
@@ -89,7 +79,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
tintColor);
|
||||
_interactionIndicatorRenderer.LoopAnimation();
|
||||
}
|
||||
#endif
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
@@ -109,12 +98,12 @@ namespace Pal3.Scene.SceneObjects
|
||||
|
||||
var shouldResetCamera = false;
|
||||
|
||||
#if PAL3
|
||||
if (ObjectInfo.Parameters[1] == 2) // 2 means interactable but executing script only
|
||||
{
|
||||
ExecuteScriptIfAny();
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (ctx.InitObjectId != ObjectInfo.Id && !IsFullyVisibleToCamera())
|
||||
{
|
||||
shouldResetCamera = true;
|
||||
@@ -123,22 +112,20 @@ namespace Pal3.Scene.SceneObjects
|
||||
ctx.PlayerActorGameObject);
|
||||
CameraFocusOnObject(ObjectInfo.Id);
|
||||
}
|
||||
#endif
|
||||
|
||||
var currentSwitchState = ObjectInfo.SwitchState;
|
||||
var switchStateBeforeInteraction = ObjectInfo.SwitchState;
|
||||
|
||||
ToggleAndSaveSwitchState();
|
||||
FlipAndSaveSwitchState();
|
||||
|
||||
#if PAL3
|
||||
if (ObjectInfo.Times == 0 && _interactionIndicatorGameObject != null)
|
||||
{
|
||||
_interactionIndicatorRenderer.Dispose();
|
||||
Object.Destroy(_interactionIndicatorRenderer);
|
||||
Object.Destroy(_interactionIndicatorGameObject);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ctx.InitObjectId == ObjectInfo.Id &&
|
||||
if (ctx.StartedByPlayer &&
|
||||
ctx.InitObjectId == ObjectInfo.Id &&
|
||||
ObjectInfo.Parameters[1] == 0)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
@@ -155,7 +142,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
yield return GetCvdModelRenderer().PlayOneTimeAnimationAsync(true,
|
||||
currentSwitchState == 0 ? 1f : -1f);
|
||||
switchStateBeforeInteraction == 0 ? 1f : -1f);
|
||||
|
||||
// Remove collider to allow player to pass through
|
||||
if (ObjectInfo.Parameters[0] == 1 && _meshCollider != null)
|
||||
@@ -164,7 +151,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
}
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
ExecuteScriptIfAny();
|
||||
yield return ActivateOrInteractWithObjectIfAnyAsync(ctx, ObjectInfo.LinkedObjectId);
|
||||
|
||||
@@ -190,34 +176,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
ctx.CurrentScene.ActivateSceneObject(flowerObject.Key);
|
||||
}
|
||||
}
|
||||
#elif PAL3A
|
||||
// Disable associated effect object if any
|
||||
if (ObjectInfo.EffectModelType != 0)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new SceneActivateObjectCommand((int)ObjectInfo.EffectModelType, 0));
|
||||
}
|
||||
// Interact with linked object if any
|
||||
if (ObjectInfo.LinkedObjectId != 0xFFFF)
|
||||
{
|
||||
SceneObject linkedObject = ctx.CurrentScene.GetSceneObject(ObjectInfo.LinkedObjectId);
|
||||
|
||||
shouldResetCamera = true;
|
||||
|
||||
yield return MoveCameraToLookAtPointAsync(
|
||||
GameBoxInterpreter.ToUnityPosition(linkedObject.ObjectInfo.GameBoxPosition),
|
||||
ctx.PlayerActorGameObject);
|
||||
|
||||
if (!string.IsNullOrEmpty(linkedObject.ObjectInfo.SfxName))
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new PlaySfxCommand(linkedObject.ObjectInfo.SfxName, 1));
|
||||
}
|
||||
|
||||
yield return ActivateOrInteractWithObjectIfAnyAsync(ctx, ObjectInfo.LinkedObjectId);
|
||||
yield return ExecuteScriptAndWaitForFinishIfAnyAsync();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (shouldResetCamera)
|
||||
{
|
||||
@@ -239,7 +197,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
Object.Destroy(_meshCollider);
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
if (_interactionIndicatorRenderer != null)
|
||||
{
|
||||
_interactionIndicatorRenderer.Dispose();
|
||||
@@ -250,9 +207,10 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
Object.Destroy(_interactionIndicatorGameObject);
|
||||
}
|
||||
#endif
|
||||
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,8 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System;
|
||||
@@ -34,7 +36,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
Bounds bounds = GetMeshBounds();
|
||||
var heightOffset = 0f;
|
||||
|
||||
#if PAL3
|
||||
if (SceneInfo.IsCity("m11") &&
|
||||
ObjectInfo.Name.Equals("_t.pol", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -54,10 +55,9 @@ namespace Pal3.Scene.SceneObjects
|
||||
};
|
||||
heightOffset = -1.7f;
|
||||
}
|
||||
#endif
|
||||
|
||||
_platformController = sceneGameObject.AddComponent<StandingPlatformController>();
|
||||
_platformController.SetBounds(bounds, ObjectInfo.LayerIndex, heightOffset);
|
||||
_platformController.Init(bounds, ObjectInfo.LayerIndex, heightOffset);
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
@@ -89,4 +89,6 @@ namespace Pal3.Scene.SceneObjects
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3A
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
using Common;
|
||||
using Core.Animation;
|
||||
using Core.DataReader.Scn;
|
||||
using Data;
|
||||
using UnityEngine;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.Teapot)]
|
||||
public sealed class TeapotObject : SceneObject
|
||||
{
|
||||
public TeapotObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public override GameObject Activate(GameResourceProvider resourceProvider, Color tintColor)
|
||||
{
|
||||
if (Activated) return GetGameObject();
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
if (ObjectInfo.SwitchState == 1)
|
||||
{
|
||||
sceneGameObject.transform.rotation *= Quaternion.Euler(0, 0, -ObjectInfo.Parameters[2]);
|
||||
}
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
if (ObjectInfo.SwitchState == 1) yield break;
|
||||
|
||||
FlipAndSaveSwitchState();
|
||||
|
||||
PlaySfxIfAny();
|
||||
|
||||
Transform objectTransform = GetGameObject().transform;
|
||||
Quaternion rotation = objectTransform.rotation;
|
||||
Quaternion targetRotation = rotation * Quaternion.Euler(0, 0, -ObjectInfo.Parameters[2]);
|
||||
|
||||
yield return AnimationHelper.RotateTransformAsync(objectTransform,
|
||||
targetRotation, 1f, AnimationCurveType.Sine);
|
||||
|
||||
yield return ExecuteScriptAndWaitForFinishIfAnyAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cf739a91f764932aaf4e80315222184
|
||||
timeCreated: 1678480297
|
||||
@@ -0,0 +1,115 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3A
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
using Common;
|
||||
using Core.Animation;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.Services;
|
||||
using Data;
|
||||
using State;
|
||||
using UnityEngine;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.ThreePhaseBridge)]
|
||||
public sealed class ThreePhaseBridgeObject : SceneObject,
|
||||
ICommandExecutor<ThreePhaseSwitchStateChangedNotification>
|
||||
{
|
||||
private const float BRIDGE_ANIMATION_DURATION = 2f;
|
||||
private const float BRIDGE_MOVEMENT_DISTANCE = 3.65f;
|
||||
|
||||
private StandingPlatformController _standingPlatformController;
|
||||
|
||||
private readonly SceneStateManager _sceneStateManager;
|
||||
|
||||
private bool _isMovingTowardsNegativeAxis = true;
|
||||
|
||||
public ThreePhaseBridgeObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
_sceneStateManager = ServiceLocator.Instance.Get<SceneStateManager>();
|
||||
}
|
||||
|
||||
public override GameObject Activate(GameResourceProvider resourceProvider, Color tintColor)
|
||||
{
|
||||
if (Activated) return GetGameObject();
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
Bounds bounds = GetMeshBounds();
|
||||
|
||||
// Parameters[5] == 1 means not walkable
|
||||
if (ObjectInfo.Parameters[5] == 0)
|
||||
{
|
||||
_standingPlatformController = sceneGameObject.AddComponent<StandingPlatformController>();
|
||||
_standingPlatformController.Init(bounds, ObjectInfo.LayerIndex);
|
||||
}
|
||||
|
||||
// Set initial position for three phase bridges in scene M13-3 and M13-4
|
||||
if (!_sceneStateManager.TryGetSceneObjectStateOverride(
|
||||
SceneInfo.CityName, SceneInfo.SceneName, ObjectInfo.Id, out _))
|
||||
{
|
||||
if (SceneInfo.Is("m13", "3") ||
|
||||
SceneInfo.Is("m13", "4"))
|
||||
{
|
||||
sceneGameObject.transform.position +=
|
||||
sceneGameObject.transform.up * -BRIDGE_MOVEMENT_DISTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
Transform transform = GetGameObject().transform;
|
||||
|
||||
Vector3 movingDirection = transform.right;
|
||||
|
||||
// Bridges in scene M13-3 and M13-4 move along Y axis
|
||||
if (SceneInfo.Is("m13", "3") ||
|
||||
SceneInfo.Is("m13", "4"))
|
||||
{
|
||||
movingDirection = transform.up;
|
||||
}
|
||||
|
||||
Vector3 finalPosition = transform.position +
|
||||
movingDirection * ((_isMovingTowardsNegativeAxis ? -1 : 1) * BRIDGE_MOVEMENT_DISTANCE);
|
||||
|
||||
yield return AnimationHelper.MoveTransformAsync(transform,
|
||||
finalPosition,
|
||||
BRIDGE_ANIMATION_DURATION,
|
||||
AnimationCurveType.Sine);
|
||||
|
||||
SaveCurrentPosition();
|
||||
}
|
||||
|
||||
public void Execute(ThreePhaseSwitchStateChangedNotification notification)
|
||||
{
|
||||
_isMovingTowardsNegativeAxis = notification.CurrentState > notification.PreviousState;
|
||||
RequestForInteraction();
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
|
||||
|
||||
if (_standingPlatformController != null)
|
||||
{
|
||||
Object.Destroy(_standingPlatformController);
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aedaf08efb8d44cda7911040f1b93b73
|
||||
timeCreated: 1678613101
|
||||
@@ -0,0 +1,157 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3A
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Common;
|
||||
using Core.Animation;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.Services;
|
||||
using Data;
|
||||
using MetaData;
|
||||
using State;
|
||||
using UnityEngine;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.ThreePhaseSwitch)]
|
||||
public sealed class ThreePhaseSwitchObject : SceneObject,
|
||||
ICommandExecutor<ThreePhaseSwitchStateChangedNotification>
|
||||
{
|
||||
private const float MAX_INTERACTION_DISTANCE = 3f;
|
||||
private const float SWITCH_ANIMATION_DURATION = 2f;
|
||||
private const float SWITCH_ROTAION_ANGLE = 30f;
|
||||
|
||||
private SceneObjectMeshCollider _meshCollider;
|
||||
|
||||
private readonly SceneStateManager _sceneStateManager;
|
||||
|
||||
// State is either -1, 0 or 1 (0 is the default state)
|
||||
private int _previousState;
|
||||
private int _currentState;
|
||||
|
||||
public ThreePhaseSwitchObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
_sceneStateManager = ServiceLocator.Instance.Get<SceneStateManager>();
|
||||
}
|
||||
|
||||
public override bool IsDirectlyInteractable(float distance)
|
||||
{
|
||||
return Activated &&
|
||||
distance < MAX_INTERACTION_DISTANCE &&
|
||||
ObjectInfo is {Times: > 0};
|
||||
}
|
||||
|
||||
public override GameObject Activate(GameResourceProvider resourceProvider, Color tintColor)
|
||||
{
|
||||
if (Activated) return GetGameObject();
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
|
||||
if (_sceneStateManager.TryGetSceneObjectStateOverride(SceneInfo.CityName, SceneInfo.SceneName,
|
||||
ObjectInfo.Id, out SceneObjectStateOverride stateOverride))
|
||||
{
|
||||
if (stateOverride.ThreePhaseSwitchPreviousState.HasValue)
|
||||
{
|
||||
_previousState = stateOverride.ThreePhaseSwitchPreviousState.Value;
|
||||
}
|
||||
if (stateOverride.ThreePhaseSwitchCurrentState.HasValue)
|
||||
{
|
||||
_currentState = stateOverride.ThreePhaseSwitchCurrentState.Value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_previousState = 0;
|
||||
_currentState = ObjectInfo.Parameters[1];
|
||||
}
|
||||
|
||||
var direction = ObjectInfo.Parameters[3] == -1 ? -1 : 1;
|
||||
sceneGameObject.transform.rotation *=
|
||||
Quaternion.Euler(0, 0, SWITCH_ROTAION_ANGLE * -_currentState * direction);
|
||||
|
||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
if (ctx.StartedByPlayer && ctx.InitObjectId == ObjectInfo.Id)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new PlayerActorLookAtSceneObjectCommand(ObjectInfo.Id));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorPerformActionCommand(ActorConstants.PlayerActorVirtualID,
|
||||
ActorConstants.ActionNames[ActorActionType.Check], 1));
|
||||
|
||||
int nextState = _currentState switch
|
||||
{
|
||||
1 or -1 => 0,
|
||||
0 when _previousState == 1 => -1,
|
||||
0 when _previousState is -1 or 0 => 1,
|
||||
_ => _currentState
|
||||
};
|
||||
|
||||
_previousState = _currentState;
|
||||
_currentState = nextState;
|
||||
|
||||
// Notify other three phase switches as well as three phase bridges
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ThreePhaseSwitchStateChangedNotification(
|
||||
ObjectInfo.Id, _previousState, _currentState));
|
||||
|
||||
PlaySfxIfAny();
|
||||
}
|
||||
|
||||
Transform objectTransform = GetGameObject().transform;
|
||||
Quaternion rotation = objectTransform.rotation;
|
||||
int direction = (_currentState - _previousState) * (ObjectInfo.Parameters[3] == -1 ? -1 : 1);
|
||||
Quaternion targetRotation = rotation * Quaternion.Euler(0, 0, SWITCH_ROTAION_ANGLE * -direction);
|
||||
|
||||
yield return AnimationHelper.RotateTransformAsync(objectTransform,
|
||||
targetRotation, SWITCH_ANIMATION_DURATION, AnimationCurveType.Sine);
|
||||
|
||||
// Save my state
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new SceneSaveGlobalThreePhaseSwitchStateCommand(
|
||||
SceneInfo.CityName, SceneInfo.SceneName, ObjectInfo.Id, _previousState, _currentState));
|
||||
}
|
||||
|
||||
public void Execute(ThreePhaseSwitchStateChangedNotification notification)
|
||||
{
|
||||
if (notification.ObjectId == ObjectInfo.Id) return; // Ignore self
|
||||
|
||||
if (_previousState != notification.PreviousState ||
|
||||
_currentState != notification.CurrentState)
|
||||
{
|
||||
// Sync state
|
||||
_previousState = notification.PreviousState;
|
||||
_currentState = notification.CurrentState;
|
||||
RequestForInteraction();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
|
||||
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8cfc3f768a1d4093a9d66489f9893b75
|
||||
timeCreated: 1678613121
|
||||
@@ -0,0 +1,170 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3A
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Common;
|
||||
using Core.Animation;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.GameBox;
|
||||
using Data;
|
||||
using MetaData;
|
||||
using Renderer;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.ToggleSwitch)]
|
||||
public sealed class ToggleSwitchObject : SceneObject
|
||||
{
|
||||
private const float MAX_INTERACTION_DISTANCE = 3f;
|
||||
|
||||
private SceneObjectMeshCollider _meshCollider;
|
||||
|
||||
public ToggleSwitchObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public override GameObject Activate(GameResourceProvider resourceProvider, Color tintColor)
|
||||
{
|
||||
if (Activated) return GetGameObject();
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
if (ObjectInfo.SwitchState == 1 && ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
CvdModelRenderer cvdModelRenderer = GetCvdModelRenderer();
|
||||
cvdModelRenderer.SetCurrentTime(cvdModelRenderer.GetDefaultAnimationDuration());
|
||||
}
|
||||
|
||||
// Add collider to block player
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
|
||||
public override bool IsDirectlyInteractable(float distance)
|
||||
{
|
||||
return Activated &&
|
||||
distance < MAX_INTERACTION_DISTANCE &&
|
||||
ObjectInfo.Times > 0;
|
||||
}
|
||||
|
||||
// TODO: Implement WuLing interaction logic for this switch
|
||||
// Can only toggle this switch if ObjectInfo.WuLing matches current player actor's WuLing.
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
if (ObjectInfo is { Times: INFINITE_TIMES_COUNT, CanOnlyBeTriggeredOnce: 1 })
|
||||
{
|
||||
ObjectInfo.Times = 1;
|
||||
}
|
||||
|
||||
if (!IsInteractableBasedOnTimesCount()) yield break;
|
||||
|
||||
FlipAndSaveSwitchState();
|
||||
|
||||
if (ctx.StartedByPlayer && ctx.InitObjectId == ObjectInfo.Id)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new PlayerActorLookAtSceneObjectCommand(ObjectInfo.Id));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorPerformActionCommand(ActorConstants.PlayerActorVirtualID,
|
||||
ActorConstants.ActionNames[ActorActionType.Check], 1));
|
||||
}
|
||||
|
||||
PlaySfxIfAny();
|
||||
|
||||
if (ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
yield return GetCvdModelRenderer().PlayOneTimeAnimationAsync(true);
|
||||
}
|
||||
else if (ObjectInfo.Parameters[1] == 180) // Special case for M12-2
|
||||
{
|
||||
Transform objectTransform = GetGameObject().transform;
|
||||
Quaternion rotation = objectTransform.rotation;
|
||||
Quaternion targetRotation = rotation * Quaternion.Euler(0, 180, 0);
|
||||
|
||||
yield return AnimationHelper.RotateTransformAsync(objectTransform,
|
||||
targetRotation, 3f, AnimationCurveType.Sine);
|
||||
|
||||
SaveCurrentYRotation();
|
||||
}
|
||||
|
||||
// Disable associated effect object if any
|
||||
if (ObjectInfo.EffectModelType != 0)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new SceneActivateObjectCommand((int)ObjectInfo.EffectModelType, 0));
|
||||
}
|
||||
|
||||
var shouldResetCamera = false;
|
||||
|
||||
// Interact with linked object if any
|
||||
if (ObjectInfo.LinkedObjectId != INVALID_SCENE_OBJECT_ID)
|
||||
{
|
||||
SceneObject linkedObject = ctx.CurrentScene.GetSceneObject(ObjectInfo.LinkedObjectId);
|
||||
Vector3 linkedObjectGameBoxPosition = linkedObject.ObjectInfo.GameBoxPosition;
|
||||
|
||||
shouldResetCamera = true;
|
||||
|
||||
if (!SceneInfo.Is("m06", "2") &&
|
||||
linkedObject.ObjectInfo.Type
|
||||
is not ScnSceneObjectType.LiftingPlatform
|
||||
and not ScnSceneObjectType.MovableCarrier
|
||||
and not ScnSceneObjectType.WaterSurface)
|
||||
{
|
||||
yield return MoveCameraToLookAtPointAsync(
|
||||
GameBoxInterpreter.ToUnityPosition(linkedObjectGameBoxPosition),
|
||||
ctx.PlayerActorGameObject);
|
||||
}
|
||||
|
||||
if (ObjectInfo.Parameters[1] == 1)
|
||||
{
|
||||
yield return ActivateOrInteractWithObjectIfAnyAsync(ctx, ObjectInfo.LinkedObjectId);
|
||||
yield return ExecuteScriptAndWaitForFinishIfAnyAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
ExecuteScriptIfAny();
|
||||
if (SceneInfo.Is("m06", "2"))
|
||||
{
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
yield return ActivateOrInteractWithObjectIfAnyAsync(ctx, ObjectInfo.LinkedObjectId);
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return ExecuteScriptAndWaitForFinishIfAnyAsync();
|
||||
}
|
||||
|
||||
if (shouldResetCamera)
|
||||
{
|
||||
ResetCamera();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7cdaaf17b86408b8b44455214f9d069
|
||||
timeCreated: 1678331711
|
||||
@@ -9,6 +9,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
using Command;
|
||||
using Command.SceCommands;
|
||||
using Common;
|
||||
using Core.Animation;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.GameBox;
|
||||
using Data;
|
||||
@@ -32,7 +33,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
// Make trap trigger rect a bit smaller for better game experience
|
||||
var tweakedRect = new GameBoxRect()
|
||||
GameBoxRect triggerRect = new()
|
||||
{
|
||||
Left = ObjectInfo.TileMapTriggerRect.Left + 1,
|
||||
Right = ObjectInfo.TileMapTriggerRect.Right - 1,
|
||||
@@ -41,7 +42,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
};
|
||||
|
||||
_triggerController = sceneGameObject.AddComponent<TilemapTriggerController>();
|
||||
_triggerController.Init(tweakedRect, ObjectInfo.LayerIndex);
|
||||
_triggerController.Init(triggerRect, ObjectInfo.LayerIndex);
|
||||
_triggerController.OnPlayerActorEntered += OnPlayerActorEntered;
|
||||
|
||||
return sceneGameObject;
|
||||
@@ -57,7 +58,11 @@ namespace Pal3.Scene.SceneObjects
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID));
|
||||
|
||||
#if PAL3
|
||||
PlaySfx("wg007");
|
||||
#elif PAL3A
|
||||
PlaySfxIfAny();
|
||||
#endif
|
||||
|
||||
// Let player actor fall down
|
||||
if (ctx.PlayerActorGameObject.GetComponent<Rigidbody>() is { } rigidbody)
|
||||
@@ -71,6 +76,15 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
yield return GetCvdModelRenderer().PlayOneTimeAnimationAsync(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if PAL3A
|
||||
Transform transform = GetGameObject().transform;
|
||||
float yOffset = GameBoxInterpreter.ToUnityDistance(ObjectInfo.Parameters[2]);
|
||||
Vector3 finalPosition = transform.position + new Vector3(0f, -yOffset, 0f);
|
||||
yield return AnimationHelper.MoveTransformAsync(transform, finalPosition, 0.5f);
|
||||
#endif
|
||||
}
|
||||
|
||||
yield return ExecuteScriptAndWaitForFinishIfAnyAsync();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3A
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Common;
|
||||
using Core.Animation;
|
||||
using Core.DataReader.Scn;
|
||||
using UnityEngine;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.WaterSurface)]
|
||||
public sealed class WaterSurfaceObject : SceneObject
|
||||
{
|
||||
private const float WATER_ANIMATION_DURATION = 3f;
|
||||
private const float WATER_DESCEND_HEIGHT = 4f;
|
||||
|
||||
public WaterSurfaceObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
if (!IsInteractableBasedOnTimesCount()) yield break;
|
||||
|
||||
PlaySfxIfAny();
|
||||
|
||||
Transform transform = GetGameObject().transform;
|
||||
Vector3 finalPosition = transform.position;
|
||||
finalPosition += new Vector3(0f, -WATER_DESCEND_HEIGHT, 0f);
|
||||
|
||||
yield return AnimationHelper.MoveTransformAsync(transform,
|
||||
finalPosition,
|
||||
WATER_ANIMATION_DURATION,
|
||||
AnimationCurveType.Sine);
|
||||
|
||||
ChangeAndSaveActivationState(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d74a7356084476ca0206494aaf1b891
|
||||
timeCreated: 1678784765
|
||||
+8
-6
@@ -3,6 +3,8 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System;
|
||||
@@ -16,14 +18,14 @@ namespace Pal3.Scene.SceneObjects
|
||||
using Data;
|
||||
using UnityEngine;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.WaterSurface)]
|
||||
public sealed class WaterSurfaceObject : SceneObject
|
||||
[ScnSceneObject(ScnSceneObjectType.WaterSurfaceRoadBlocker)]
|
||||
public sealed class WaterSurfaceRoadBlockerObject : SceneObject
|
||||
{
|
||||
private const float WATER_ANIMATION_DURATION = 4f;
|
||||
|
||||
private readonly SceneManager _sceneManager;
|
||||
|
||||
public WaterSurfaceObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
public WaterSurfaceRoadBlockerObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
_sceneManager = ServiceLocator.Instance.Get<SceneManager>();
|
||||
@@ -68,14 +70,14 @@ namespace Pal3.Scene.SceneObjects
|
||||
// * 当水面机关开启之后,需要将地砖类型为土壤的地砖设置为可通过
|
||||
private void UpdateTileMapWhenConditionMet(bool setSoilFloorAsObstacle)
|
||||
{
|
||||
#if PAL3
|
||||
if (SceneInfo.IsCity("m09"))
|
||||
{
|
||||
_sceneManager.GetCurrentScene()
|
||||
.GetTilemap()
|
||||
.MarkFloorKindAsObstacle(NavFloorKind.Soil, setSoilFloorAsObstacle);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
File renamed without changes.
@@ -0,0 +1,153 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if PAL3A
|
||||
|
||||
namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
using System.Collections;
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Common;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.GameBox;
|
||||
using Data;
|
||||
using MetaData;
|
||||
using Renderer;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
[ScnSceneObject(ScnSceneObjectType.WuLingSwitch)]
|
||||
public sealed class WuLingSwitchObject : SceneObject
|
||||
{
|
||||
private const float MAX_INTERACTION_DISTANCE = 3f;
|
||||
|
||||
private SceneObjectMeshCollider _meshCollider;
|
||||
|
||||
public WuLingSwitchObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
||||
: base(objectInfo, sceneInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public override GameObject Activate(GameResourceProvider resourceProvider, Color tintColor)
|
||||
{
|
||||
if (Activated) return GetGameObject();
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
if (ObjectInfo.SwitchState == 1 && ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
CvdModelRenderer cvdModelRenderer = GetCvdModelRenderer();
|
||||
cvdModelRenderer.SetCurrentTime(cvdModelRenderer.GetDefaultAnimationDuration());
|
||||
}
|
||||
|
||||
if (ObjectInfo.IsNonBlocking == 0)
|
||||
{
|
||||
if (!(ObjectInfo.SwitchState == 1 && ObjectInfo.Parameters[0] == 1))
|
||||
{
|
||||
// Add collider to block player
|
||||
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
|
||||
}
|
||||
}
|
||||
|
||||
return sceneGameObject;
|
||||
}
|
||||
|
||||
public override bool IsDirectlyInteractable(float distance)
|
||||
{
|
||||
return Activated &&
|
||||
distance < MAX_INTERACTION_DISTANCE &&
|
||||
ObjectInfo.Times > 0 &&
|
||||
ObjectInfo.Parameters[1] is 0 or 2; // 0 means directly interactable,
|
||||
// 2 means interactable but executing script only
|
||||
}
|
||||
|
||||
// TODO: Implement WuLing interaction logic for this switch
|
||||
// Can only toggle this switch if ObjectInfo.WuLing matches current player actor's WuLing.
|
||||
public override IEnumerator InteractAsync(InteractionContext ctx)
|
||||
{
|
||||
if (ObjectInfo is { Times: INFINITE_TIMES_COUNT, CanOnlyBeTriggeredOnce: 1 })
|
||||
{
|
||||
ObjectInfo.Times = 1;
|
||||
}
|
||||
|
||||
if (!IsInteractableBasedOnTimesCount()) yield break;
|
||||
|
||||
FlipAndSaveSwitchState();
|
||||
|
||||
if (ctx.StartedByPlayer &&
|
||||
ctx.InitObjectId == ObjectInfo.Id)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new PlayerActorLookAtSceneObjectCommand(ObjectInfo.Id));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorPerformActionCommand(ActorConstants.PlayerActorVirtualID,
|
||||
ActorConstants.ActionNames[ActorActionType.Check], 1));
|
||||
}
|
||||
|
||||
PlaySfxIfAny();
|
||||
|
||||
if (ModelType == SceneObjectModelType.CvdModel)
|
||||
{
|
||||
yield return GetCvdModelRenderer().PlayOneTimeAnimationAsync(true);
|
||||
|
||||
// Remove collider to allow player to pass through
|
||||
if (ObjectInfo.Parameters[0] == 1 && _meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
}
|
||||
}
|
||||
|
||||
// Disable associated effect object if any
|
||||
if (ObjectInfo.EffectModelType != 0)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new SceneActivateObjectCommand((int)ObjectInfo.EffectModelType, 0));
|
||||
}
|
||||
|
||||
var shouldResetCamera = false;
|
||||
|
||||
// Interact with linked object if any
|
||||
if (ObjectInfo.LinkedObjectId != INVALID_SCENE_OBJECT_ID)
|
||||
{
|
||||
SceneObject linkedObject = ctx.CurrentScene.GetSceneObject(ObjectInfo.LinkedObjectId);
|
||||
|
||||
shouldResetCamera = true;
|
||||
|
||||
yield return MoveCameraToLookAtPointAsync(
|
||||
GameBoxInterpreter.ToUnityPosition(linkedObject.ObjectInfo.GameBoxPosition),
|
||||
ctx.PlayerActorGameObject);
|
||||
|
||||
if (!string.IsNullOrEmpty(linkedObject.ObjectInfo.SfxName))
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new PlaySfxCommand(linkedObject.ObjectInfo.SfxName, 1));
|
||||
}
|
||||
|
||||
yield return ActivateOrInteractWithObjectIfAnyAsync(ctx, ObjectInfo.LinkedObjectId);
|
||||
yield return ExecuteScriptAndWaitForFinishIfAnyAsync();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
if (shouldResetCamera)
|
||||
{
|
||||
ResetCamera();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8488fa934eb847fa8b3284275729f9c9
|
||||
timeCreated: 1678321302
|
||||
@@ -71,7 +71,7 @@ namespace Pal3.Script
|
||||
|
||||
private readonly int _codepage;
|
||||
private readonly BinaryReader _scriptDataReader;
|
||||
private PalScriptExecutionMode _executionMode;
|
||||
private ScriptExecutionMode _executionMode;
|
||||
private readonly object[] _registers;
|
||||
private readonly Dictionary<int, int> _globalVariables;
|
||||
private readonly Dictionary<int, int> _localVariables = new ();
|
||||
@@ -102,7 +102,7 @@ namespace Pal3.Script
|
||||
SceScriptBlock scriptBlock,
|
||||
Dictionary<int, int> globalVariables,
|
||||
int codepage,
|
||||
PalScriptExecutionMode executionMode = PalScriptExecutionMode.Break)
|
||||
ScriptExecutionMode executionMode = ScriptExecutionMode.Asynchronous)
|
||||
{
|
||||
ScriptType = scriptType;
|
||||
ScriptId = scriptId;
|
||||
@@ -181,7 +181,7 @@ namespace Pal3.Script
|
||||
_scriptDataReader.BaseStream.Position < _scriptDataReader.BaseStream.Length)
|
||||
{
|
||||
ExecuteNextCommand();
|
||||
if (_executionMode == PalScriptExecutionMode.Break) break;
|
||||
if (_executionMode == ScriptExecutionMode.Asynchronous) break;
|
||||
}
|
||||
|
||||
_isExecuting = false;
|
||||
@@ -363,7 +363,7 @@ namespace Pal3.Script
|
||||
public void Execute(ScriptChangeExecutionModeCommand command)
|
||||
{
|
||||
if (!_isExecuting) return;
|
||||
_executionMode = (PalScriptExecutionMode)command.Mode;
|
||||
_executionMode = (ScriptExecutionMode)command.Mode;
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
|
||||
Loaded 100 of 111 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user