private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
コード例 #2
0
    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);
コード例 #3
0
        protected override SlotItem GetSlot(int index)
        {
            SplineRoad roadFromId = SplineManager.GetRoadFromId(index);

            if (!roadFromId.IsValid)
            {
                return(null);
            }
            return(new SlotItem(index, roadFromId.Entry));
        }
コード例 #4
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
コード例 #5
0
 private void Awake()
 {
     // Singleton setup
     if (instance != null && instance != this)
     {
         Destroy(gameObject);
         return;
     }
     instance = this;
     splines  = new List <BezierSpline>();
 }
コード例 #6
0
        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();
        }
コード例 #7
0
 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();
 }
コード例 #8
0
    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);
    }
コード例 #9
0
 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();
 }
コード例 #10
0
 private void Start()
 {
     splineIndex = SplineManager.AddSpline(spline);
     OnActivate();
 }
コード例 #11
0
 private void UpdateSelectedSpline()
 {
     this.SetSplineRoad((this.m_paramRoad.Value != -1) ? SplineManager.GetRoadFromId(this.m_paramRoad.Value) : SplineRoad.Null);
 }
コード例 #12
0
 private void Awake()
 {
     instance = this;
 }
コード例 #13
0
 // Start is called before the first frame update
 void Awake()
 {
     //setup singleton
     instance = this;
 }
コード例 #14
0
 public override void Activate()
 {
     base.Activate();
     base.SetSpline(SplineManager.GetPlayableZone());
 }
コード例 #15
0
 private void action_Reset()
 {
     UndoManager.RecordUndo();
     SplineManager.GetPlayableZone().Reset();
     UndoManager.CommitUndo();
 }