コード例 #1
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);
        }
    }
コード例 #2
0
ファイル: Door.cs プロジェクト: mlgodzilla/Decompiled-Rust
    public override void ServerInit()
    {
        base.ServerInit();
        if (Door.nonWalkableArea < 0)
        {
            Door.nonWalkableArea = NavMesh.GetAreaFromName("Not Walkable");
        }
        if (Door.animalAgentTypeId < 0)
        {
            NavMeshBuildSettings settingsByIndex = NavMesh.GetSettingsByIndex(1);
            Door.animalAgentTypeId = ((NavMeshBuildSettings) ref settingsByIndex).get_agentTypeID();
        }
        if (Object.op_Equality((Object)this.NavMeshVolumeAnimals, (Object)null))
        {
            this.NavMeshVolumeAnimals = (NavMeshModifierVolume)((Component)this).get_gameObject().AddComponent <NavMeshModifierVolume>();
            this.NavMeshVolumeAnimals.set_area(Door.nonWalkableArea);
            this.NavMeshVolumeAnimals.AddAgentType(Door.animalAgentTypeId);
            this.NavMeshVolumeAnimals.set_center(Vector3.get_zero());
            this.NavMeshVolumeAnimals.set_size(Vector3.get_one());
        }
        if (this.HasSlot(BaseEntity.Slot.Lock))
        {
            this.canNpcOpen = false;
        }
        if (!this.canNpcOpen)
        {
            if (Door.humanoidAgentTypeId < 0)
            {
                NavMeshBuildSettings settingsByIndex = NavMesh.GetSettingsByIndex(0);
                Door.humanoidAgentTypeId = ((NavMeshBuildSettings) ref settingsByIndex).get_agentTypeID();
            }
            if (Object.op_Equality((Object)this.NavMeshVolumeHumanoids, (Object)null))
            {
                this.NavMeshVolumeHumanoids = (NavMeshModifierVolume)((Component)this).get_gameObject().AddComponent <NavMeshModifierVolume>();
                this.NavMeshVolumeHumanoids.set_area(Door.nonWalkableArea);
                this.NavMeshVolumeHumanoids.AddAgentType(Door.humanoidAgentTypeId);
                this.NavMeshVolumeHumanoids.set_center(Vector3.get_zero());
                this.NavMeshVolumeHumanoids.set_size(Vector3.op_Addition(Vector3.op_Addition(Vector3.get_one(), Vector3.get_up()), Vector3.get_forward()));
            }
        }
        else if (Object.op_Equality((Object)this.NpcTriggerBox, (Object)null))
        {
            if (this.isSecurityDoor)
            {
                M0 m0 = ((Component)this).get_gameObject().AddComponent <NavMeshObstacle>();
                ((NavMeshObstacle)m0).set_carving(true);
                ((NavMeshObstacle)m0).set_center(Vector3.get_zero());
                ((NavMeshObstacle)m0).set_size(Vector3.get_one());
                ((NavMeshObstacle)m0).set_shape((NavMeshObstacleShape)1);
            }
            this.NpcTriggerBox = (NPCDoorTriggerBox) new GameObject("NpcTriggerBox").AddComponent <NPCDoorTriggerBox>();
            this.NpcTriggerBox.Setup(this);
        }
        AIInformationZone forPoint = AIInformationZone.GetForPoint(((Component)this).get_transform().get_position(), (BaseEntity)null);

        if (!Object.op_Inequality((Object)forPoint, (Object)null) || !Object.op_Equality((Object)this.NavMeshLink, (Object)null))
        {
            return;
        }
        this.NavMeshLink = forPoint.GetClosestNavMeshLink(((Component)this).get_transform().get_position());
    }