private void Awake() { if (instance == null) { instance = this; } }
protected override JobHandle OnUpdate(JobHandle inputDeps) { float deltaTime = Time.DeltaTime; Entities.ForEach((Entity entity, ref Translation translation, ref Rotation rotation, ref SplineMovementData splineData) => { splineData.movementDelay -= deltaTime; if (!splineData.isActive && splineData.movementDelay <= 0) { splineData.isActive = true; splineData.progress -= splineData.movementDelay; // subtract movementDelay from progress to make sure we start in the right position and don't lose time } if (!splineData.isActive) { translation.Value.y = -1.0f; // hide below the level for now return; } BezierSpline spline = SplineManager.GetSpline(splineData.splineIndex); if (splineData.goingForward) { splineData.progress += deltaTime / splineData.duration; if (splineData.progress > 1f) { if (splineData.mode == SplineWalkerMode.Once) { splineData.progress = 1f; } else if (splineData.mode == SplineWalkerMode.Loop) { splineData.progress -= 1f; } else { splineData.progress = 2f - splineData.progress; splineData.goingForward = false; } } } else { splineData.progress -= deltaTime / splineData.duration; if (splineData.progress < 0f) { splineData.progress = -splineData.progress; splineData.goingForward = true; } } Vector3 position = spline.GetPoint(splineData.progress); translation.Value = position; if (splineData.lookForward) { rotation.Value = quaternion.LookRotation(spline.GetDirection(splineData.progress), Vector3.up); } }).WithoutBurst().Run(); return(default);
protected override SlotItem GetSlot(int index) { SplineRoad roadFromId = SplineManager.GetRoadFromId(index); if (!roadFromId.IsValid) { return(null); } return(new SlotItem(index, roadFromId.Entry)); }
private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(this.gameObject); } }
private void Awake() { // Singleton setup if (instance != null && instance != this) { Destroy(gameObject); return; } instance = this; splines = new List <BezierSpline>(); }
protected override void OnAssignSlot(int id, Inventory.Entry entry) { base.OnAssignSlot(id, entry); if (entry == null || !entry.IsValid) { SplineManager.DestroyRoad(id); return; } SplineRoad splineRoad = SplineManager.GetRoadFromId(id); if (!splineRoad.IsValid) { splineRoad = SplineManager.CreateRoad(id); } SplineInventory.Entry entry2 = (SplineInventory.Entry)entry; splineRoad.Entry = entry2; splineRoad.Width = entry2.DefaultWidth; splineRoad.UpdateSpline(); }
private void UpdateList() { this.treeView.BeginUpdate(); this.treeView.Nodes.Clear(); this.imageList.Images.Clear(); for (int i = 0; i < 8; i++) { SplineRoad roadFromId = SplineManager.GetRoadFromId(i); bool flag = false; string text = null; string text2 = null; if (roadFromId.IsValid) { SplineInventory.Entry entry = roadFromId.Entry; if (entry.IsValid) { text2 = entry.IconName; if (!this.imageList.Images.ContainsKey(text2)) { this.imageList.Images.Add(text2, entry.Icon); } text = entry.DisplayName; flag = true; } } if (!flag) { text2 = "empty16"; if (!this.imageList.Images.ContainsKey(text2)) { this.imageList.Images.Add(text2, Resources.empty16); } text = Localizer.Localize("PARAM_EMPTY"); } SplineTreeItem tag = new SplineTreeItem(i, roadFromId); TreeNode treeNode = this.treeView.Nodes.Add(text); treeNode.ImageKey = text2; treeNode.SelectedImageKey = text2; treeNode.Tag = tag; } this.UpdateSelection(); this.treeView.EndUpdate(); }
public bool AttemptToCatchSpline(SplineManager aSplineManager, float aReach, ref bool aTooCloseToOldSpline, ref int aPointsIndex, ref Vector2[] someCurrentPoints, ref Vector2[] someOldPoints, ref Vector2 aBoost) { Vector2 closestPoint = aSplineManager.GetClosestPoint(transform.position, ref aPointsIndex, ref someCurrentPoints, ref aBoost); if (Vector2.Distance(transform.position, closestPoint) <= aReach) { if (aTooCloseToOldSpline && IsOldSpline(someOldPoints, someCurrentPoints)) { return(false); } transform.position = closestPoint; return(true); } if (Vector2.Distance(transform.position, closestPoint) > aReach && IsOldSpline(someOldPoints, someCurrentPoints)) { aTooCloseToOldSpline = false; } return(false); }
private void AssignSplineId(int id, SplineInventory.Entry entry) { Win32.SetRedraw(this, false); UndoManager.RecordUndo(); if (!entry.IsValid) { SplineManager.DestroyRoad(id); } else { SplineRoad splineRoad = SplineManager.GetRoadFromId(id); if (!splineRoad.IsValid) { splineRoad = SplineManager.CreateRoad(id); } splineRoad.Entry = entry; splineRoad.UpdateSpline(); } UndoManager.CommitUndo(); this.UpdateList(); Win32.SetRedraw(this, true); this.Refresh(); }
private void Start() { splineIndex = SplineManager.AddSpline(spline); OnActivate(); }
private void UpdateSelectedSpline() { this.SetSplineRoad((this.m_paramRoad.Value != -1) ? SplineManager.GetRoadFromId(this.m_paramRoad.Value) : SplineRoad.Null); }
private void Awake() { instance = this; }
// Start is called before the first frame update void Awake() { //setup singleton instance = this; }
public override void Activate() { base.Activate(); base.SetSpline(SplineManager.GetPlayableZone()); }
private void action_Reset() { UndoManager.RecordUndo(); SplineManager.GetPlayableZone().Reset(); UndoManager.CommitUndo(); }