Exemple #1
0
 private void CreateOverlayIcon()
 {
     if (!((UnityEngine.Object)HarvestWhenReadyOverlayIcon != (UnityEngine.Object)null) && (UnityEngine.Object)GetComponent <AttackableBase>() == (UnityEngine.Object)null)
     {
         HarvestWhenReadyOverlayIcon = Util.KInstantiate(Assets.UIPrefabs.HarvestWhenReadyOverlayIcon, GameScreenManager.Instance.worldSpaceCanvas, null).GetComponent <RectTransform>();
         OccupyArea component  = GetComponent <OccupyArea>();
         Extents    extents    = component.GetExtents();
         KPrefabID  component2 = GetComponent <KPrefabID>();
         TransformExtensions.SetPosition(position: component2.HasTag(GameTags.Hanging) ? new Vector3((float)(extents.x + extents.width / 2) + 0.5f, (float)(extents.y + extents.height)) : new Vector3((float)(extents.x + extents.width / 2) + 0.5f, (float)extents.y), transform: HarvestWhenReadyOverlayIcon.transform);
         RefreshOverlayIcon(null);
     }
 }
 private void OnMove()
 {
     if (partitionerEntry.IsValid())
     {
         Extents extents = occupyArea.GetExtents();
         GameScenePartitioner.Instance.UpdatePosition(partitionerEntry, extents.x, extents.y);
     }
     else
     {
         partitionerEntry = GameScenePartitioner.Instance.Add("GasDrowningMonitor.OnSpawn", gameObject, occupyArea.GetExtents(), GameScenePartitioner.Instance.liquidChangedLayer, new Action <object>(OnLiquidChanged));
     }
     CheckDrowning();
 }
Exemple #3
0
        public Splat(DecorProvider provider)
        {
            this = default(Splat);
            AttributeInstance decor = provider.decor;

            this.decor = 0f;
            if (decor != null)
            {
                this.decor = decor.GetTotalValue();
            }
            if (provider.HasTag(GameTags.Stored))
            {
                this.decor = 0f;
            }
            int num = Grid.PosToCell(provider.gameObject);

            if (Grid.IsValidCell(num))
            {
                if (!Grid.Transparent[num] && Grid.Solid[num] && (UnityEngine.Object)provider.simCellOccupier == (UnityEngine.Object)null)
                {
                    this.decor = 0f;
                }
                if (this.decor != 0f)
                {
                    provider.cellCount = 0;
                    this.provider      = provider;
                    int num2 = 5;
                    AttributeInstance decorRadius = provider.decorRadius;
                    if (decorRadius != null)
                    {
                        num2 = (int)decorRadius.GetTotalValue();
                    }
                    Orientation orientation = Orientation.Neutral;
                    if ((bool)provider.rotatable)
                    {
                        orientation = provider.rotatable.GetOrientation();
                    }
                    OccupyArea occupyArea = provider.occupyArea;
                    extents                      = occupyArea.GetExtents(orientation);
                    extents.x                    = Mathf.Max(extents.x - num2, 0);
                    extents.y                    = Mathf.Max(extents.y - num2, 0);
                    extents.width                = Mathf.Min(extents.width + num2 * 2, Grid.WidthInCells - 1);
                    extents.height               = Mathf.Min(extents.height + num2 * 2, Grid.HeightInCells - 1);
                    partitionerEntry             = GameScenePartitioner.Instance.Add("DecorProvider.SplatCollectDecorProviders", provider.gameObject, extents, GameScenePartitioner.Instance.decorProviderLayer, provider.onCollectDecorProvidersCallback);
                    solidChangedPartitionerEntry = GameScenePartitioner.Instance.Add("DecorProvider.SplatSolidCheck", provider.gameObject, extents, GameScenePartitioner.Instance.solidChangedLayer, provider.refreshPartionerCallback);
                    AddDecor();
                }
            }
        }
    protected override void OnSpawn()
    {
        OccupyArea component = GetComponent <OccupyArea>();

        if ((Object)component != (Object)null)
        {
            this.extents = component.GetExtents();
        }
        else
        {
            Building component2 = GetComponent <Building>();
            this.extents = component2.GetExtents();
        }
        Extents extents = new Extents(this.extents.x - 1, this.extents.y - 1, this.extents.width + 2, this.extents.height + 2);

        partitionerEntry = GameScenePartitioner.Instance.Add("AnimTileable.OnSpawn", base.gameObject, extents, GameScenePartitioner.Instance.objectLayers[(int)objectLayer], OnNeighbourCellsUpdated);
        UpdateEndCaps();
    }
Exemple #5
0
    public NoiseSplat(NoisePolluter setProvider, float death_time = 0f)
    {
        deathTime = death_time;
        dB        = 0;
        radius    = 5;
        if (setProvider.dB != null)
        {
            dB = (int)setProvider.dB.GetTotalValue();
        }
        int cell = Grid.PosToCell(setProvider.gameObject);

        if (!NoisePolluter.IsNoiseableCell(cell))
        {
            dB = 0;
        }
        if (dB != 0)
        {
            setProvider.Clear();
            OccupyArea occupyArea = setProvider.occupyArea;
            baseExtents = occupyArea.GetExtents();
            provider    = setProvider;
            position    = setProvider.transform.GetPosition();
            if (setProvider.dBRadius != null)
            {
                radius = (int)setProvider.dBRadius.GetTotalValue();
            }
            if (radius != 0)
            {
                int x = 0;
                int y = 0;
                Grid.CellToXY(cell, out x, out y);
                int      widthInCells  = occupyArea.GetWidthInCells();
                int      heightInCells = occupyArea.GetHeightInCells();
                Vector2I vector2I      = new Vector2I(x - radius, y - radius);
                Vector2I v             = vector2I + new Vector2I(radius * 2 + widthInCells, radius * 2 + heightInCells);
                vector2I                     = Vector2I.Max(vector2I, Vector2I.zero);
                v                            = Vector2I.Min(v, new Vector2I(Grid.WidthInCells - 1, Grid.HeightInCells - 1));
                effectExtents                = new Extents(vector2I.x, vector2I.y, v.x - vector2I.x, v.y - vector2I.y);
                partitionerEntry             = GameScenePartitioner.Instance.Add("NoiseSplat.SplatCollectNoisePolluters", setProvider.gameObject, effectExtents, GameScenePartitioner.Instance.noisePolluterLayer, setProvider.onCollectNoisePollutersCallback);
                solidChangedPartitionerEntry = GameScenePartitioner.Instance.Add("NoiseSplat.SplatSolidCheck", setProvider.gameObject, effectExtents, GameScenePartitioner.Instance.solidChangedLayer, setProvider.refreshPartionerCallback);
            }
        }
    }
Exemple #6
0
        protected override void OnSpawn()
        {
            OccupyArea component = base.GetComponent <OccupyArea>();

            if (component != null)
            {
                this.extents = component.GetExtents();
            }
            else
            {
                Building component2 = base.GetComponent <Building>();
                this.extents = component2.GetExtents();
            }
            Extents extents = new Extents(this.extents.x - 1, this.extents.y - 1, this.extents.width + 2, this.extents.height + 2);

            this.partitionerEntry = GameScenePartitioner.Instance.Add("AnimStairs.OnNeighbourCellsUpdated", base.gameObject, extents, GameScenePartitioner.Instance.objectLayers[(int)this.objectLayer], new Action <object>(this.OnNeighbourCellsUpdated));
            //int cell = Grid.PosToCell(base.gameObject);
            //this.partitionerEntry2 = GameScenePartitioner.Instance.Add("AnimStairs.OnNavChanged", base.gameObject, cell, GameScenePartitioner.Instance.validNavCellChangedLayer, new Action<object>(this.OnNavChanged));
            this.UpdateEndCaps();
            //this.UpadateRotation();
        }
    protected override void OnSpawn()
    {
        base.OnSpawn();
        solidPartitionerEntry = GameScenePartitioner.Instance.Add("EntityPreview", base.gameObject, occupyArea.GetExtents(), GameScenePartitioner.Instance.solidChangedLayer, OnAreaChanged);
        if (objectLayer != ObjectLayer.NumLayers)
        {
            objectPartitionerEntry = GameScenePartitioner.Instance.Add("EntityPreview", base.gameObject, occupyArea.GetExtents(), GameScenePartitioner.Instance.objectLayers[(int)objectLayer], OnAreaChanged);
        }
        Singleton <CellChangeMonitor> .Instance.RegisterCellChangedHandler(base.transform, OnCellChange, "EntityPreview.OnSpawn");

        OnAreaChanged(null);
    }