Example #1
0
    public override void Update()
    {
        this.time += 0.05f;
        if (!EntityUtilities.CheckProperty(this.theEntity.entityId, "PathingBlocks"))
        {
            return;
        }

        EntityMoveHelper moveHelper = this.theEntity.moveHelper;

        //If we are close, be done with it.
        float dist = Vector3.Distance(this.position, this.theEntity.position);

        if (dist < 0.1f)
        {
            DisplayLog("I am within 1f of the block: " + dist);
            BlockValue block = GameManager.Instance.World.GetBlock(new Vector3i(this.position));
            if (block.type != BlockValue.Air.type || block.Block.GetBlockName() != "PathingCube")
            {
                DisplayLog("I am close enough to this block: " + block.Block.GetBlockName());
//                if (block.Block.GetBlockName() == "bedroll")
//                {
//                    Debug.Log("At a bedroll");
//                    if (this.theEntity.emodel != null && this.theEntity.emodel.avatarController != null)
//                    {
//                        DisplayLog("Turning into crawler");
//                        int sleeperPose = (int)this.theEntity.rand.RandomRange(0, 9);
//                        this.theEntity.emodel.avatarController.TriggerSleeperPose(sleeperPose);
//                       // this.theEntity.emodel.avatarController.TurnIntoCrawler(true);
////                        this.theEntity.emodel.avatarController.GetAnimator().enabled =false;
//                    }

//                }
                moveHelper.Stop();
                this.theEntity.navigator.clearPath();
                this.time = 40f;
                return;
            }
        }

        //Check if we are blocked, which may indicate that we are at a door that we want to open.
        //if (moveHelper.IsBlocked && moveHelper.BlockedTime > 0.09)
        //{
        //    DisplayLog("I am blocked, and I've been blocked for more than 0.010 seconds. I cannot keep going.");
        //    moveHelper.Stop();
        //    this.time = 40f;
        //    return;
        //}
    }