Ejemplo n.º 1
0
 private void OnDisable()
 {
     NavMeshLink.RemoveTracking(this);
     this.m_LinkInstance.Remove();
 }
Ejemplo n.º 2
0
    public override void ServerInit()
    {
        NavMeshBuildSettings settingsByIndex;

        base.ServerInit();
        if (Door.nonWalkableArea < 0)
        {
            Door.nonWalkableArea = NavMesh.GetAreaFromName("Not Walkable");
        }
        if (Door.animalAgentTypeId < 0)
        {
            settingsByIndex        = NavMesh.GetSettingsByIndex(1);
            Door.animalAgentTypeId = settingsByIndex.agentTypeID;
        }
        if (this.NavMeshVolumeAnimals == null)
        {
            this.NavMeshVolumeAnimals      = base.gameObject.AddComponent <NavMeshModifierVolume>();
            this.NavMeshVolumeAnimals.area = Door.nonWalkableArea;
            this.NavMeshVolumeAnimals.AddAgentType(Door.animalAgentTypeId);
            this.NavMeshVolumeAnimals.center = Vector3.zero;
            this.NavMeshVolumeAnimals.size   = Vector3.one;
        }
        if (this.HasSlot(BaseEntity.Slot.Lock))
        {
            this.canNpcOpen = false;
        }
        if (!this.canNpcOpen)
        {
            if (Door.humanoidAgentTypeId < 0)
            {
                settingsByIndex          = NavMesh.GetSettingsByIndex(0);
                Door.humanoidAgentTypeId = settingsByIndex.agentTypeID;
            }
            if (this.NavMeshVolumeHumanoids == null)
            {
                this.NavMeshVolumeHumanoids      = base.gameObject.AddComponent <NavMeshModifierVolume>();
                this.NavMeshVolumeHumanoids.area = Door.nonWalkableArea;
                this.NavMeshVolumeHumanoids.AddAgentType(Door.humanoidAgentTypeId);
                this.NavMeshVolumeHumanoids.center = Vector3.zero;
                this.NavMeshVolumeHumanoids.size   = (Vector3.one + Vector3.up) + Vector3.forward;
            }
        }
        else if (this.NpcTriggerBox == null)
        {
            if (this.isSecurityDoor)
            {
                NavMeshObstacle navMeshObstacle = base.gameObject.AddComponent <NavMeshObstacle>();
                navMeshObstacle.carving = true;
                navMeshObstacle.center  = Vector3.zero;
                navMeshObstacle.size    = Vector3.one;
                navMeshObstacle.shape   = NavMeshObstacleShape.Box;
            }
            this.NpcTriggerBox = (new GameObject("NpcTriggerBox")).AddComponent <NPCDoorTriggerBox>();
            this.NpcTriggerBox.Setup(this);
        }
        AIInformationZone forPoint = AIInformationZone.GetForPoint(base.transform.position, null);

        if (forPoint != null && this.NavMeshLink == null)
        {
            this.NavMeshLink = forPoint.GetClosestNavMeshLink(base.transform.position);
        }
    }